Our company has purchased the SFTP and SSL product. I am using C# console apps to download files. Is there a code snippet anywhere that will show me how to display kbs/sec and % downloaded for the current file?

asked 17 Sep '10, 14:37

Kyle%20Donohue's gravatar image

Kyle Donohue
16
accept rate: 0%

edited 17 Sep '10, 15:18

Rebex%20KB's gravatar image

Rebex KB ♦♦
258519


Hello.

1) Getting transfer rate [kbs/sec]

Since Rebex (S)Ftp component 2010-03-11 Version 3.0.3723 the transfer rate can be obtained by setting TransferProgress event as follows:

ftp.Connect( ... );
ftp.Login(..., ...);
ftp.TransferProgress +=new FtpTransferProgressEventHandler(ftp_TransferProgress);
ftp.PutFile(...,...); or ftp.GetFile(...,...);

static void  ftp_TransferProgress(object sender, FtpTransferProgressEventArgs e)
{
  Console.WriteLine("Upload rate (B/sec): {0} \tBytes {1:D12} {2}",
        e.BytesPerSecond, e.BytesTransferred, e.Finished?"end":"");
}

2) Getting % of downloaded size

This can be solved similarly as previous question. There is no direct support for download/upload percentage but you can calculate this by exploiting the TransferProgess event as in the previous case. It containts e.BytesTransferred property. For percentage evaluation you need the total size of the file. The remote file size (in case of GetFile) can be obtained by ftp.GetFileLength(...); the size of the local file (in case of PutFile) by FileInfo info = new FileInfo(...); info.Length.

link

answered 20 Sep '10, 13:45

Vit%20Zyka's gravatar image

Vit Zyka
912
accept rate: 8%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×152
×141
×10
×3

Asked: 17 Sep '10, 14:37

Seen: 449 times

Last updated: 21 Mar '11, 21:22