The file can already be moved because of a path problem. The Rename method is still used. The reason is renameto= ""; Here the path does not contain the file name, and the relative path and the absolute path are not right, so I have never believed that others said rename can move the file. Now knot paste, thank you! In order for Yimeimei to find the answer, I post the code and do a demonstration:
Ftp:10.62.80.x/temp/aa.pdf file path to move (source file path)
Ftp:10.62.80.x/youku/aa.pdf to move the directory (the file path after the move)
Instance:
FtpWebRequest reqftp;
Try
{
Reqftp = (ftpwebrequest) ftpwebrequest.create (New Uri ("Ftp://10.62.80.x/TEMP/aa.pdf")); x represents the actual IP, where the unknown is replaced by
Reqftp.method = WebRequestMethods.Ftp.Rename;
Reqftp.keepalive = false;
Reqftp.renameto = "~/youku/aa.pdf"; Here is the absolute path, we can change according to the actual situation
Reqftp.usebinary = true;
Reqftp.credentials = new NetworkCredential (LoginName, PassWord);
FtpWebResponse response = (ftpwebresponse) reqftp.getresponse ();
Stream FtpStream = Response. GetResponseStream ();
Ftpstream.close ();
Response. Close ();
}
catch (Exception ex)
{
}
The top is my help-csdn.
FTP Server Move file directory