Hi all,
I am using the below code to upload a file to FTP server.
It will hit error 'The remote server returned an error: (550) File unavailable (e.g., file not found, no access).' when i try to FTP to subdirectory. no problem directly ftp to the root directory.
Can anyone help to advise how to FTP to a sub directory? or suggest a free ftp class?
Thanks a lot.
Dim clsRequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://" & FTPHost & "/" & sFileName), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential(FTPID, FTPPW)
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
clsRequest.UsePassive = False
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
clsRequest.UsePassive = False
For Each File In files
sFileName = System.IO.Path.GetFileName(File.ToString)
Dim bFile() As Byte = System.IO.File.ReadAllBytes(LocalFilePath & "\" & sFileName)
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
Next
I am using the below code to upload a file to FTP server.
It will hit error 'The remote server returned an error: (550) File unavailable (e.g., file not found, no access).' when i try to FTP to subdirectory. no problem directly ftp to the root directory.
Can anyone help to advise how to FTP to a sub directory? or suggest a free ftp class?
Thanks a lot.
Dim clsRequest As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://" & FTPHost & "/" & sFileName), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential(FTPID, FTPPW)
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
clsRequest.UsePassive = False
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
clsRequest.UsePassive = False
For Each File In files
sFileName = System.IO.Path.GetFileName(File.ToString)
Dim bFile() As Byte = System.IO.File.ReadAllBytes(LocalFilePath & "\" & sFileName)
Dim clsStream As System.IO.Stream = clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
Next