Controls [vb.net] WebClient 파일 업로드 프로세스 바 / BackgroundWorker Progress Display
페이지 정보
본문
Private WithEvents uploader As New WebClient
Private Sub UploadFile(sourcePath As String, destinationAddress As String)
uploader.UploadFileAsync(New Uri(destinationAddress), sourcePath)
End Sub
Private Sub uploader_UploadProgressChanged(sender As Object, e As UploadProgressChangedEventArgs) Handles uploader.UploadProgressChanged
SetProgress(Convert.ToInt32(100 * e.BytesSent / e.TotalBytesToSend))
End Sub
Private Sub uploader_UploadFileCompleted(sender As Object, e As UploadFileCompletedEventArgs) Handles uploader.UploadFileCompleted
NotifyUploadComplete()
End Sub
Private Sub SetProgress(progress As Integer)
If ProgressBar1.InvokeRequired Then
ProgressBar1.Invoke(New Action(Of Integer)(AddressOf SetProgress), progress)
Else
ProgressBar1.Value = progress
End If
End Sub
Private Sub NotifyUploadComplete()
If InvokeRequired Then
Invoke(New MethodInvoker(AddressOf NotifyUploadComplete))
Else
MessageBox.Show("Upload complete")
End If
End Sub
- 이전글[vb.net] OpenFileDialog Example 23.06.21
- 다음글[vb.net] Round Button 23.06.07
댓글목록
등록된 댓글이 없습니다.