在 FTP 服务器上重命名文件时出现“(553) 文件名不允许”
Getting "(553) File name not allowed" when renaming file on FTP server
在我的应用程序中,我在 FTP 服务器一个目录中有文件,我将该文件源移动到目标路径。在此过程中,当我移动选定的源文件时,源文件不会显示在源路径中,它只会显示在目标路径中。
我尝试了下面的代码,但出现错误:
string sourceurl = "ftp://ftp.com/Mainfoder/Folder1/subfolder/subsubfolder/"
string Targetpat =
"ftp://ftp.com/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;
Uri serverFile = new Uri(sourceurl + filename);
request = (FtpWebRequest)FtpWebRequest.Create(serverFile);
request.Method = WebRequestMethods.Ftp.Rename;
request.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
request.RenameTo = Targetpat+"/"+newfilename;//folders without filename
response = (FtpWebResponse)request.GetResponse();
Stream ftpStream = response.GetResponseStream();
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: The remote server returned an error: (553) File name now allowed.
response = (FtpWebResponse)request.GetResponse(); //This line throwing the above exception
request.RenameTo = newfilename
:当我仅设置 newfilename
时,它仅重命名该源相同的文件名。
如何将此文件移动到同一 FTP 服务器中的另一个目录?
谁能告诉我。谢谢
作为I wrote you already before:
request.RenameTo
takes a path only.
所以这是错误的:
string Targetpat =
"ftp://ftp.com/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;
request.RenameTo = Targetpat+"/"+newfilename;
应该是:
string Targetpat =
"/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;
request.RenameTo = Targetpat+"/"+newfilename;
在我的应用程序中,我在 FTP 服务器一个目录中有文件,我将该文件源移动到目标路径。在此过程中,当我移动选定的源文件时,源文件不会显示在源路径中,它只会显示在目标路径中。
我尝试了下面的代码,但出现错误:
string sourceurl = "ftp://ftp.com/Mainfoder/Folder1/subfolder/subsubfolder/"
string Targetpat =
"ftp://ftp.com/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;
Uri serverFile = new Uri(sourceurl + filename);
request = (FtpWebRequest)FtpWebRequest.Create(serverFile);
request.Method = WebRequestMethods.Ftp.Rename;
request.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
request.RenameTo = Targetpat+"/"+newfilename;//folders without filename
response = (FtpWebResponse)request.GetResponse();
Stream ftpStream = response.GetResponseStream();
An unhandled exception of type 'System.Net.WebException' occurred in System.dll Additional information: The remote server returned an error: (553) File name now allowed.
response = (FtpWebResponse)request.GetResponse(); //This line throwing the above exception
request.RenameTo = newfilename
:当我仅设置 newfilename
时,它仅重命名该源相同的文件名。
如何将此文件移动到同一 FTP 服务器中的另一个目录?
谁能告诉我。谢谢
作为I wrote you already before:
request.RenameTo
takes a path only.
所以这是错误的:
string Targetpat =
"ftp://ftp.com/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;
request.RenameTo = Targetpat+"/"+newfilename;
应该是:
string Targetpat =
"/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;
request.RenameTo = Targetpat+"/"+newfilename;