Just looking at various ways of ftp’ing a file in c#.
I noticed some examples do:
streamReader.ReadToEnd()
then convert to bytes, then send the file in one go.
while others do a:
while (contentLength != 0)
stream.write(buff, 0, contentLength);
contentLength = fileStream.Read(buff, 0, buffLength);
Is sending the file 2048 at a time for larger files, while the other method is fine for files in the 10-50K range?
If you can only read or write the file all at once, you have to allocate as much space as is required for the entire file. That can be cumbersome, especially when you don’t know how big the file is going to be in advance. It’s also bad for slower connections, because you won’t be able to use any of the file until the whole thing is finished, which is obviously terrible for applications like streaming movies or audio. Buffering is a good general strategy to handle this sort of case.