I'm trying to upload a file to an ftp server using WebClient, but I keep getting the same error are listed below: The remote server returned an error: (401) Unauthorized.
As you can see in the code example, I have tried 4 different uploads methods in try catch form. Can you help me with this problem?
Dim wc As New WebClient
wc.Credentials = New NetworkCredential(ftp.username, ftp.password)
Try 'UploadFile Method (String, String)
Dim dddd As Byte() = wc.UploadFile("https://ftp.something/something/something/", serverpath)
Catch ex1 As Exception
Try 'UploadFile Method (Uri, String)
Dim dddd As Byte() = wc.UploadFile(ftp.myUri, serverpath)
Catch ex2 As Exception
Try 'UploadFile Method(Of String, String, String)
Dim dddd As Byte() = wc.UploadFile("https://ftp.something/something/something/", "POST", serverpath)
Catch ex33 As Exception
Try 'UploadFile Method (Uri, String, String)
Dim dddd As Byte() = wc.UploadFile(ftp.myUri, "POST", serverpath)
Catch ex As Exception
End Try
End Try
End Try
End Try