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