Results 1 to 2 of 2

Thread: [RESOLVED] FTP file upload report %Ge of progress in Progress bar control

  1. #1

    Thread Starter
    PowerPoster make me rain's Avatar
    Join Date
    Sep 2008

    Resolved [RESOLVED] FTP file upload report %Ge of progress in Progress bar control

    How can i get the progress percentage of file uploading And display in the progress bar, which object does this job
    here is my code

    PrivateSub BckgWkr_DoWork(sender AsObject, e As System.ComponentModel.DoWorkEventArgs) HandlesBckgWkr.DoWork

    Dim ByteArray() As Byte = File.ReadAllBytes(_UPLOADINGFILEPATH)
    Dim Fc As New FtpClient(_HOST, "remoteclient", "remoteclient")

    Dim Wc As New WebClient
    With Wc
    .Credentials = New NetworkCredential(_HOST, "remoteclient", "remoteclient")

    '' How do i get the Numeric value for the progress done here
    '' i mean the percentage of file transferred
    '' That may be like the Uploaded quantity / total file size * 100
    '' But how can i get the Uploaded quantity ?

    BckgWkr.ReportProgress(.UploadData(_UPLOADINGFILE_FTPSERVERPATH, ByteArray).Length)

    End With
    e.Result = ByteArray.Length()


    Private Sub BckgWkr_ProgressChanged(sender As Object, e AsSystem.ComponentModel.ProgressChangedEventArgs) Handles

    '' this doing nothing
    TsPbar.Value = e.ProgressPercentage

    End Sub
    The averted nuclear war
    My notes:

    PrOtect your PC. MSDN Functions .OOP LINUX forum
    .LINQ LINQ videous
    If some one helps you please rate them with out fail , forum doesn't expects any thing other than this

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: FTP file upload report %Ge of progress in Progress bar control

    Don't use a BackgroundWorker for this. There's no point and you're actually preventing yourself from being able to measure progress. The WebClient has its own asynchronous methods. Instead of calling UploadData on a secondary thread, call UpdateDataAsync or UploadDataTaskAsync on the UI thread. If you call UploadDataAsync then you can handle the UploadProgressChanged and UploadDataCompleted events.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width