Sending files thru Sockets
Well i have the following code to send a file:
Code:
FileStream fs = new FileStream(this._fileName, FileMode.Open);
byte[] buffer = new byte[4096];
int bufferLength = buffer.Length;
while(fs.Read(buffer, 0, buffer.Length) > 0) {
e.SocketClient.Send(buffer);
}
It sends the file, but the received file is completly screwed up. It looks like it just repeats the first chunk of data sent all over the file. I tried puting a Thread.Sleep(1000) meaning it would wait 1second between each buffer send and it worked wonderfully. The only problem is it takes forever to send files. What do you think about it? Did I forget something?