How to rewind a file

D

**Developer**

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
 
K

Ken Halter

**Developer** said:
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 ;-)
 
T

tomb

Ken said:
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
 
D

**Developer**

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top