I have made a server and a client in C# which transfers files. But when transferring it pauses for some seconds and then continues. I have uploaded a video on YouTube to demonstrate: http://www.youtube.com/watch?v=GGRKRW6ihLo
As you can see it sometime pauses and then continues.
Receiver:
using (var writer = new StreamWriter(Path.Combine(_localPath, file.FileName))) {
var buffer = new byte[_bufferSize];
while (file.Transferred < file.Size && _active) {
int read = ns.Read(buffer, 0, _bufferSize);
writer.BaseStream.Write(buffer, 0, read);
file.Transferred += read;
}
writer.Close();
}
Sender:
using (var reader = new StreamReader(file.FilePath)) {
var buffer = new byte[_bufferSize];
while (file.Transferred < file.Size && _active) {
int read = reader.BaseStream.Read(buffer, 0, _bufferSize);
ns.Write(buffer, 0, read);
file.Transferred += read;
}
reader.Close();
}