Im trying to create a little server which can send files to clients. One thing im stuck on is actually breaking up the binary file and sending blocks of it at a time. What I want to do have is some kind of function where i just pass the position i want to read from in the file and it returns the bytes:
Public Function ReturnBlock(byval MyFile as string, Byval Position as integer, byval SizeToRead as integer) as byte()
Dim FS as new Filestream(MyFile)
Dim bytes(SizeToRead) as byte
FS.SEEK(Position, SeekOrigin.Begin)
FS.READ(Bytes, 0, SizeToRead) 'im trying to read 1024 at a time
FS.CLOSE
Return Bytes
End Function
The problem im running into is if the file is 1025 bytes long and I stick the position at 1024 how can it tell that theres only 1 byte left to read???
Thanks!
Public Function ReturnBlock(byval MyFile as string, Byval Position as integer, byval SizeToRead as integer) as byte()
Dim FS as new Filestream(MyFile)
Dim bytes(SizeToRead) as byte
FS.SEEK(Position, SeekOrigin.Begin)
FS.READ(Bytes, 0, SizeToRead) 'im trying to read 1024 at a time
FS.CLOSE
Return Bytes
End Function
The problem im running into is if the file is 1025 bytes long and I stick the position at 1024 how can it tell that theres only 1 byte left to read???
Thanks!