Reputation: 3345
I am trying to upload files from a local folder to a ftp server folder which works fine when doing it with filezilla. I keep getting this error:
Quote: the remote server returned an error: (550) file unavailable (e.g., file not found, no access). Code:
'....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
Upvotes: 0
Views: 921
Reputation: 3345
resolved issue...
clsrequest.usepassive = true
frequest.usebinary = false
and included subfolder in ftp path
Upvotes: 0
Reputation: 7146
If you haven't already, grab a copy of WireShark and inspect the packets being sent by FileZilla and your custom client. From here you'll be able to inspect the working request and the non-working request. From analyzing the differences, you should be able to determine what you need to fix to get things working.
Upvotes: 1
Reputation: 6258
I don't have an answer, but i do have a method you can use to find the answer ... download and install a packet sniffer and watch the ftp traffic. the control channel conversation shouldn't be hard to follow. see what the difference is between your conversation and filezilla's conversation and you should be able to figure it out.
Upvotes: 1