Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.3k views
in .NET FTP by (200 points)
Hi there, I am uploading a whole lot of files in a loop and am trying to update a text box on the screen with the bytes uploaded so that the user can see some progress.
I am using the free version of edtftp.
I am using the BytesTransferred event, but all I see is the final byte count for the last file uploaded.
The rest of the time the application is unresponsive.

Can someone provide an example of how to do this?
I know some part of the code needs to run in a separate thread... The new BackgroundWorker component seems to be the easiest way to do this.
I am just not sure what part of the code runs where?
Please, any help would be appreciated.

Antz

4 Answers

0 votes
by (540 points)
Hi. I am using that event and it works well..

Maybe you can post your code here and we'll see what is wrong.

=)
0 votes
by (200 points)
Hi efhatch thanks for your reply.
Below is the event handler... nothing complicated here:

Private Sub FtpConnection1_BytesTransferred(ByVal sender As Object, ByVal e As EnterpriseDT.Net.Ftp.BytesTransferredEventArgs) Handles FtpConnection1.BytesTransferred

txtBytes.Text = e.RemoteFile + " : " + e.ByteCount.ToString + " of " + iFileSize.ToString

End Sub

iFileSize is a global variable that holds the size of the file I am uploading.
The problem is that I am uploading anywhere between 5 and 10 files of size between 3MB to 10MB.
While the files are uploading my whole app is unresponsive. As soon as the last file is finished uploading I get the text in the txtBytes text box. The text is the info about the very last file and it is the final byte count. I am trying to display a progressive byte count that updates on the screen as each file is uploaded.
According to other threads in here I need to use a separate thread to do the upload, which will make the main form responsive and able to display the data.
The thing is I am not sure how to set it up.
Antz
0 votes
by (540 points)
What direction are you going?

Upload a file one at a time? or do you want it to be uploaded simultaneously?

but before anything else try to put this code in the event:

txtBytes.Text = e.RemoteFile + " : " + e.ByteCount.ToString + " of " + iFileSize.ToString
Application.DoEvents()

that might solve you problem. HTH.
0 votes
by (200 points)
Thanks efhatch,

Application.DoEvents() did the trick.

Thanks very much!
Antz

Categories

...