获取“(553)文件名不允许"在 FTP 服务器上重命

Getting quot;(553) File name not allowedquot; when renaming file on FTP server(获取“(553)文件名不允许在 FTP 服务器上重命名文件时)
本文介绍了获取“(553)文件名不允许"在 FTP 服务器上重命名文件时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我在 FTP 服务器的一个目录中有文件,我将该文件源移动到目标路径.在这个过程中,当我移动选定的源文件时,源文件不会显示在源路径中,它只会显示在目标路径中.

我尝试了以下代码,但出现错误:

string sourceurl = "ftp://ftp.com/Mainfoder/Folder1/subfolder/subsubfolder/"字符串 Targetpat ="ftp://ftp.com/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;Uri serverFile = new Uri(sourceurl + 文件名);请求 = (FtpWebRequest)FtpWebRequest.Create(serverFile);request.Method = WebRequestMethods.Ftp.Rename;request.Credentials = new NetworkCredential(ftpUserID, ftpPassword);request.RenameTo = Targetpat+"/"+newfilename;//没有文件名的文件夹响应 = (FtpWebResponse)request.GetResponse();流 ftpStream = response.GetResponseStream();

<块引用>

System.dll 中出现System.Net.WebException"类型的未处理异常附加信息:远程服务器返回错误:(553) 文件名现在允许.

response = (FtpWebResponse)request.GetResponse();//这行抛出了上面的异常

request.RenameTo = newfilename:当我只设置 newfilename 时,它只重命名该源相同的文件名.

如何将此文件移动到同一 FTP 服务器中的另一个目录?

谁能告诉我.谢谢你

解决方案

作为 我之前已经给你写过:

<块引用>

request.RenameTo 仅采用路径.

所以这是错误的:

字符串 Targetpat ="ftp://ftp.com/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;request.RenameTo = Targetpat+"/"+newfilename;

应该是:

字符串 Targetpat ="/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;request.RenameTo = Targetpat+"/"+newfilename;

In my application, I have files in FTP server one directory and I move that file source to target path. In this process, when I move selected source file that source file will not show in the source path, it will show only in target path.

I tried this below code, but I am getting error:

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: when I set only newfilename, it renames that source same file name only.

How can I move this file to another directory within in same FTP server?

Please can anyone tell me. Thank you

解决方案

As I wrote you already before:

request.RenameTo takes a path only.

So this is wrong:

string Targetpat =
    "ftp://ftp.com/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;
request.RenameTo = Targetpat+"/"+newfilename;

It should be:

string Targetpat =
    "/Mainfoder/DownloadedFiles/"+subfolder+"/"+todaydatefolder+"/"+susubfolder;
request.RenameTo = Targetpat+"/"+newfilename;

这篇关于获取“(553)文件名不允许"在 FTP 服务器上重命名文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)