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