This project has moved. For the latest updates, please go here.

TftpOnProgress event with percentage

Apr 22, 2014 at 10:21 AM
Hi,
Is there any chance to get the percentage of a transfer in the event TftpOnProgress instead of bytes. In my case I use the library to implement a download server?
Coordinator
Jun 16, 2014 at 7:02 AM
Yes, no Problem. I just uploaded an update to the library. Check the ITftpTransfer.OnProgress - Event. It includes everything necessary to calculate the percentage. The SampleClient demo application also shows how it's done:
var client = new TftpClient("127.0.0.1");
var transfer = client.Receive("Testfile.txt");
transfer.OnProgress += new TftpProgressHandler(transfer_OnProgress);
transfer.Start();

static void transfer_OnProgress(ITftpTransfer transfer, TftpTransferProgress progress)
{
  if (progress.TotalBytes > 0)
    Console.WriteLine((progress.TransferredBytes * 100) / TotalBytes + "% completed");
  else
    Console.WriteLine(progress.TransferredBytes + "Bytes received");
}
Jul 2, 2014 at 9:52 AM
Thanks man,
I will include new options on my project.