Start reading from beginning of file.
Posted on 2004-08-16
Hi, I have a program that reads data from a binary file, 4kilobytes at a time (using INPUT). My problem is, when i close that file and open a new file to do the same, the program does not start from the beginning of the file, and just reacts as if it has reached the end of the file. How can i tell it to begin reading from the beginning of the file again? Heres my code:
Earlier in the code, a file is opened with the following line:
Open CD.FileName For Binary As #1
FileSize = FileLen(CD.FileName) / 4096
The following code is then executed everytime i want the next 4k of data from that file:
cmdSend.Enabled = False
Dim DataChunk As String
If FilePos < FileSize Then
FilePos = FilePos + 1
DataChunk = Input(4096, #1)
lblConnection = "Transferring... " & Math.Round((FilePos / FileSize * 100), 0) & "%"
Ws.SendData "FileEnd" & FileLen(CD.FileName)
FilePos = 0
cmdSend.Enabled = True