Hi
I would like to ask, why when i try to open file , that has been sent -
its empty. Size of sent file is proper, but for example when it's pdf -
acrobat reader says " file might be damaged"
Here is my send finction
try
{
if (Client.Connected)
{
this.Text = "Sending File";
String line = null;
file = new FileStream(sfName, FileMode.Open);
fileLength = file.Length;
Client.Client.Send(fName, 0, fName.Length,
SocketFlags.None);
int BytesCount = 0;
mylegth = fileLength / 100;
long i = 0;
this.smoothprogressBar1.Value = 0;
byte[] buffer = new byte[64];
BytesCount = file.Read(buffer, 0, 64);
while ((BytesCount != 0))
{
i += Client.Client.Send(buffer);
this.smoothprogressBar1.Value = (int) ((i *
100)/ fileLength);
BytesCount = file.Read(buffer,0,64);
}
file.Close();
Client.Close();
}
this.Dispose();
}
Jon Skeet [C# MVP] - 17 Dec 2005 17:51 GMT
> I would like to ask, why when i try to open file , that has been sent -
> its empty. Size of sent file is proper, but for example when it's pdf -
[quoted text clipped - 22 lines]
> {
> i += Client.Client.Send(buffer);
It looks like you're sending the whole buffer, whether or not you've
actually read the whole buffer. See
http://www.pobox.com/~skeet/csharp/readbinary.html
Note that you shouldn't do this kind of thing in the UI thread, and you
shouldn't be updating the UI from any other thread...

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too