1
我试图上传文件到FTP服务器使用WebClient,但我不断收到同样的错误如下: 远程服务器返回一个错误: (401)未经授权。Webclient:远程服务器返回一个错误:(401)未授权
正如您可以在代码示例中看到的,我尝试了4种不同的尝试抓取形式的上传方法。你能帮我解决这个问题吗?
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