[英]ftp file transfer using vb.net without any third party tools
I am writing the code using vb.net for file transfer from remote machine to local machine with out using any third party tools 我正在使用vb.net编写代码,用于从远程计算机到本地计算机的文件传输,而无需使用任何第三方工具
This my code 这是我的代码
Dim reqFTP As FtpWebRequest
Dim filepath As String
Dim filename As String
Dim filename1 As String
Dim ftpserverip As String
Dim ftpuserid As String
Dim ftpPassword As String
Try
filename1 = TxtRemoteFile.Text
filepath = TxtLocalFile.Text
filename = Locfname.Text
ftpserverip = TxtServerIP.Text
ftpuserid = TxtUserName.Text
ftpPassword = TxtPwd.Text
Dim outputStream As FileStream = New FileStream((filepath + ("\\" + filename)), FileMode.Create)
reqFTP = CType(FtpWebRequest.Create(New Uri(("ftp://" _
+ (ftpserverip + ("/" + filename1))))), FtpWebRequest)
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile
reqFTP.UseBinary = True
reqFTP.Credentials = New NetworkCredential(ftpuserid, ftpPassword)
Dim response As FtpWebResponse = CType(reqFTP.GetResponse, FtpWebResponse)
outputStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
but am getting error like" remote server returned error :(550) fi 但出现错误,例如“远程服务器返回错误:(550)fi
I had the same issue. 我遇到过同样的问题。 I was not including httpdocs in the remote path.
我没有在远程路径中包含httpdocs。 Example: ftp://ftp.websitename.com/httpdocs/filenametocopy.txt
范例: ftp : //ftp.websitename.com/httpdocs/filenametocopy.txt
System.Net.WebRequest.Create("ftp://ftp.websitename.com/httpdocs/filenametocopy.txt")
Permission was denied because i was trying to write the file outside the root directory. 权限被拒绝,因为我试图在根目录之外写入文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.