我試圖將文件從本地文件夾上傳到ftp服務器文件夾,該文件夾在使用filezilla進行時效果很好。 我不斷收到此錯誤:ftp上傳不起作用
Quote: 遠程服務器返回錯誤:(550)文件不可用(例如,文件未找到,無法訪問)。 代碼:
」 ...... ftppath =「TP://192.xxx.xx.xx/%2f/feedb/gnip/
Public Sub uploadFTP(ByVal ftpPath As String, ByVal localPath As String,
ByVal username As String, ByVal psswd As String)
Dim item As String = String.Empty
item = "F20110210022920.xml"
Try
Dim fs As FileStream = File.OpenRead(localPath & item)
Dim buffer As Byte() = New Byte(fs.Length - 1) {}
fs.Read(buffer, 0, buffer.Length)
fs.Close()
Dim clsRequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create(ftpPath & item), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential(username, psswd)
clsRequest.KeepAlive = False
clsRequest.Proxy = Nothing
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
clsRequest.Timeout = 10000
Dim bFile() As Byte = File.ReadAllBytes(localPath & item)
Dim clsStream As Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
Catch ex As Exception
End Try
我可以只使用Fiddler?好吧,不要介意我想這是爲http請求onlt – vbNewbie 2011-02-13 02:19:17