Upload issue in VB.NET

Last post 06-18-2013, 3:25 AM by Estherimage. 2 replies.
Sort Posts: Previous Next
  •  01-29-2012, 10:47 PM 72864

    Upload issue in VB.NET

    VB project is migrated to VB.NET. In that I am facing one issue.
    Need to upload the configuration file to the device. For that, in the Background_DoWork, we are initializing the form which contains progressbar and then

    AddHandler Me.webClient.UploadProgressChanged, AddressOf Me.UpdateProgressBar

     is provided.
    In the UpdateProgressBar method, we are incrementing the progress bar value.
     
    But I am not able to see the progress bar. Hope UploadProgressChanged event is not triggering.
     
    Anybody could help me to resolve this is appreciated.
     
    Code for the above issue is as below
     

    Public Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

    Dim isTimerCreated As Boolean = True

    If (frmTimer1 Is Nothing) Then

    isTimerCreated = False

    ElseIf (frmTimer1.IsDisposed) Then

    isTimerCreated = False

    End If

    If (Not isTimerCreated) Then

    frmTimer1 = New frmTimer()

    Dim handle As IntPtr = frmTimer1.Handle

    frmTimer1.Timer1.Enabled = True

    frmTimer1.Timer1.Start()

    frmTimer1.Show()

    End If

    AddHandler Me.webClient.UploadProgressChanged, AddressOf Me.UpdateProgressBar

    Me.isUploaded = Me.FtpFileTransfer(strFullFilePath, "PUT")

    frmTimer1.Timer1.Stop()

    frmTimer1.Close()
    End Sub
     
     
     

    Public Sub UpdateProgressBar(ByVal sender As Object, ByVal e As System.Net.UploadFileCompletedEventArgs)

    Try

    Dim realProgress As Integer

    If frmTimer1.ProgressBar1.InvokeRequired Then

    frmTimer1.ProgressBar1.Invoke(New UploadFileCompletedEventHandler(AddressOf UpdateProgressBar), sender, e)

    Exit Sub

    End If

    frmTimer1.ProgressBar1.Value = CInt(frmTimer1.Min + ((frmTimer1.Max - frmTimer1.Min) * realProgress) / 100)

    Catch ex As WebException

    If ex.Status = WebExceptionStatus.SendFailure Then

    MsgBox("FTPServer connection failure" & strCrLf & "Upload Aborted", MsgBoxStyle.Exclamation)

    'FtpFileUpLoad = False

    Exit Sub

    End If

    End Try

    End Sub

     
  •  01-30-2012, 6:45 AM 72867 in reply to 72864

    Re: Upload issue in VB.NET

    Hi Ranjinikg,
     
    1. Method "UploadProgressChanged" is not a part of DotNetGallery, if it is your own method, I think you need to check your code which fire this method.
     
    2. And the progressbar, do you mean the progressbar of the DotNetGallery upload function?  DotNetGallery does not provided the method to custom the progressbar image. So I am not sure what is the "frmTimer1.ProgressBar1.Value" mean.
     
    Can you explain your question in detail?
     
    Regards,
     
    Ken 
  •  06-18-2013, 3:25 AM 77570 in reply to 72864

    Re: Upload issue in VB.NET

    Why don't you use a mature image uploading api,as mentioned above,"UploadProgressChanged" is not a part of DotNetGallery,so you may have to worked out the method by yourself.
View as RSS news feed in XML