Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / December 2005

Tip: Looking for answers? Try searching our database.

How to rewind a file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
**Developer** - 13 Dec 2005 20:19 GMT
Assume that the first line of a file is read with:

InputLine = LineInput(FileNum)

I believe a file can be rewound as follows:
(So that the first line can be reread)
FileClose(FileNum) 'Rewind

FileOpen(FileNum, mDataInFullPath, OpenMode.Input)

InputLine = LineInput(FileNum)

Isn't there a better way?

Thanks
Ken Halter - 13 Dec 2005 20:32 GMT
> Assume that the first line of a file is read with:
>
> InputLine = LineInput(FileNum)

Looks like the Seek method is still supported so..... no need to close, just
use Seek.

Seek(FileNum, 1)

I'd provide the sample code the VB6 migration wizard provided but.... VSNet
crashed and burned when I hit F1 (or, maybe 90 seconds isn't enough to open
help anymore <sigh>)  to look up help on the Seek method so.....

fwiw, I've written VB6 apps that use Seek to mark (and store) the beginning
of each line as they're read so I can return to any line in the file at
will. Surely, there's similar support in .Net (if you can keep it running
anyway ;-)

Signature

Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..

**Developer** - 13 Dec 2005 20:56 GMT
I wasn't sure if Seek worked with LineInput.

Thanks

>> Assume that the first line of a file is read with:
>>
[quoted text clipped - 13 lines]
> file at will. Surely, there's similar support in .Net (if you can keep it
> running anyway ;-)
tomb - 14 Dec 2005 02:14 GMT
>  
>
[quoted text clipped - 19 lines]
>
>  

Yes, seek(FileNum,1) is the way, and seek(FileNum) still returns the
current position.  This is regardless of the method used to read the file.

Tom
**Developer** - 14 Dec 2005 17:59 GMT
thanks.

I noticed you send HTML.  I was under the impression that many do not like
to receive HTML.

I like HTML but avoid it because it may be inconvenient for some.

Is that an obsolete notion?

Ken Halter wrote:

Assume that the first line of a file is read with:

InputLine = LineInput(FileNum)

Looks like the Seek method is still supported so..... no need to close, just
use Seek.

Seek(FileNum, 1)

I'd provide the sample code the VB6 migration wizard provided but.... VSNet
crashed and burned when I hit F1 (or, maybe 90 seconds isn't enough to open
help anymore <sigh>)  to look up help on the Seek method so.....

fwiw, I've written VB6 apps that use Seek to mark (and store) the beginning
of each line as they're read so I can return to any line in the file at
will. Surely, there's similar support in .Net (if you can keep it running
anyway ;-)

Yes, seek(FileNum,1) is the way, and seek(FileNum) still returns the current
position.  This is regardless of the method used to read the file.

Tom

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.