End of file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
When I read from a file through a binaryReader, how can I know when the end
of the file is reached?
thanks
 
Michael said:
When I read from a file through a binaryReader, how can I know when
the end of the file is reached?

That depends on how you're reading it - what exactly are you doing with
it? (Also, do you definitely need a BinaryReader? I've seen a lot of
people using them when they really only need a stream. Just a thought.)
 
I would just use the NetworkStream stream or the socket directly and read
until bytesToRead is read or 0 is returned from read(). You should send the
len first or in some fixed len header so you know how many bytes are coming.
Another good reason for this information upfront is you may want to reject
the request for a 3+GB upload or for some other reasons (i.e. no space,
wrong name, wrong secret, etc).
 
What is the NetworkStream and how can I use it to send files over the
internet??
thanks for ur help
 
Back
Top