lucky3, on 09 September 2012 - 02:50 AM, said:
Now you have all the information you need, to know what file uploading MyAdvancedWebClient raised events, and update just the right listview items subitem. Good luck!
You have given me all this info and i still cant get it work properly
This is my pathetic attempt
Private Class MyAdvancedWebClient
Inherits WebClient
Public Property FileName As String
Get
Return myFileName
End Get
Set(ByVal value As String)
myFileName = value
End Set
End Property
Private myFileName As String
End Class
Private Sub MyAdvancedWebClient_UploadProgressChanged(ByVal sender As Object, ByVal e As System.Net.UploadProgressChangedEventArgs)
Dim n As Integer = 0
For Each myFileName In OpenFileDialog1.FileNames
Dim itm As New ListViewItem With {.Text = OpenFileDialog1.SafeFileNames(N)}
itm.SubItems.Add(e.ProgressPercentage)
ListView1.Items.Add(itm)
n = n + 1
Next myFileName
End Sub
Private Sub BrowseBut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BrowseBut.Click
Dim dr As DialogResult = Me.OpenFileDialog1.ShowDialog()
If (dr = System.Windows.Forms.DialogResult.OK) Then
' Read the files
Dim N As Integer = 0
For Each myFileName In OpenFileDialog1.FileNames
Try
Dim MyAdvancedWebClient As New MyAdvancedWebClient
AddHandler MyAdvancedWebClient.UploadProgressChanged, AddressOf MyAdvancedWebClient_UploadProgressChanged
AddHandler MyAdvancedWebClient.UploadFileCompleted, AddressOf MyAdvancedWebClient_UploadFileCompleted
Dim myUri As New Uri("ftp://testingcom/public_html/hello123/" & OpenFileDialog1.SafeFileNames(N))
MyAdvancedWebClient.Credentials = New System.Net.NetworkCredential("", "")
'Now you do the uploading
MyAdvancedWebClient.UploadFileAsync(myUri, OpenFileDialog1.FileNames(N))
Catch SecEx As SecurityException
' The user lacks appropriate permissions to read files, discover paths, etc.
MessageBox.Show("Security error. Please contact your administrator for details.\n\n" & _
"Error message: " & SecEx.Message & "\n\n" & _
"Details (send to Support):\n\n" & SecEx.StackTrace)
Catch ex As Exception
' Could not load the File - probably permissions-related.
MessageBox.Show(("Cannot Select File: " & myFileName.Substring(myFileName.LastIndexOf("\"c)) & _
". You may not have permission to read the file, or " + "it may be corrupt." _
& ControlChars.Lf & ControlChars.Lf & "Reported error: " & ex.Message))
End Try
N = N + 1
Next myFileName
End If
I know it makes absolutely no scene at all but at this point i am completely lost.

New Topic/Question
Reply





MultiQuote


|