Closed
Description
Hello,
I have a small problem and do not know if this is my mistake or a bug.
I use the SftpClient to upload a file. For this I use BeginUploadFile with Filestream.
In the end I check with uploadhandler.UploadedBytes if the file was uploaded correctly.
But there always comes a different result out and only occasionally the right number.
Here is the simplified code:
SftpClient client = new SftpClient(host, port, user, password);
client.Connect();
FileStream fileStream = new FileStream(source, FileMode.Open);
SftpUploadAsyncResult uploadhandler = client.BeginUploadFile(fileStream, target, null, null) as SftpUploadAsyncResult;
while (!uploadhandler.IsCompleted)
{
Thread.Sleep(500);
}
client.EndUploadFile(uploadhandler);
FileInfo fi = new FileInfo(source);
if (uploadhandler.UploadedBytes == Convert.ToUInt64(fi.Length))
{
return true;
} else {
return false
}
Metadata
Metadata
Assignees
Labels
No labels