无法连接到FTP:(553)不允许的文件名 [英] Can't connect to FTP: (553) File name not allowed

查看:8620
本文介绍了无法连接到FTP:(553)不允许的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要FTP文件到一个目录。在.NET中我必须使用一个文件的目标文件夹来创建连接,所以我手动把Blank.dat使用FTP服务器上。我检查了访问(ls -l命令),它是-rw-R - R--。但是,当我尝试连接到FTP文件夹中,我得到:远程服务器返回错误:(553)文件名不允许从服务器返回。研究我已经做了说,这可能arrise从一个权限问题,但正如我已经说过我有权限查看该文件,并可以运行该文件夹LS。还有什么其他原因可能导致这个问题,有没有办法连接到文件夹,而无需指定文件?

 字节[]缓冲区;
            流reqStream;
            的FileStream流;
            FtpWebResponse响应;
            的FtpWebRequest请求=(的FtpWebRequest)FtpWebRequest.Create(新开放的我们(的String.Format(FTP:// {0} / {1},SRV,DIR)));
            request.Method = WebRequestMethods.Ftp.UploadFile;
            request.Credentials =新的NetworkCredential(UID,PASS);
            request.UseBinary = TRUE;
            request.Timeout = 60000 * 2;
            对于(INT FL = 0; FL< files.Length; FL ++)
            {
                request.KeepAlive =(!files.Length = FL);
                流= File.OpenRead(Path.Combine(目录,文件[FL]));
                reqStream = request.GetRequestStream();
                缓冲区=新的字节[4096 * 2];
                INT NREAD = 0;
                而((NREAD = stream.Read(缓冲液,0,buffer.Length))!= 0)
                {
                    reqStream.Write(缓冲液,0,NREAD);
                }
                stream.Close();
                reqStream.Close();

                响应=(FtpWebResponse)request.GetResponse();
                response.Close();
            }
 

解决方案

虽然回复旧的文章只是认为它可能帮助别人。

当您创建FTP URL请确保您不包括该登录的默认目录。

例如,这是我被指定和我得到的异常553文件名不允许例外的路径

  FTP://myftpip/gold/central_p2/inbound/article_list/jobs/abc.txt
 

这是我使用过的默认目录金/ central_p2.so所提供的URL变成无效的,因为它试图找到默认directory.I修改了我的URL字符串相应的完整路径,并能摆脱登录例外。

我的修正URL看起来像

  FTP://myftpip/inbound/article_list/jobs/abc.txt
 

谢谢

审计局

I need to FTP a file to a directory. In .Net I have to use a file on the destination folder to create a connection so I manually put Blank.dat on the server using FTP. I checked the access (ls -l) and it is -rw-r--r--. But when I attempt to connect to the FTP folder I get: "The remote server returned an error: (553) File name not allowed" back from the server. The research I have done says that this may arrise from a permissions issue but as I have said I have permissions to view the file and can run ls from the folder. What other reasons could cause this issue and is there a way to connect to the folder without having to specify a file?

            byte[] buffer;
            Stream reqStream;
            FileStream stream;
            FtpWebResponse response;
            FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(new Uri(string.Format("ftp://{0}/{1}", SRV, DIR)));
            request.Method = WebRequestMethods.Ftp.UploadFile;
            request.Credentials = new NetworkCredential(UID, PASS);
            request.UseBinary = true;
            request.Timeout = 60000 * 2;
            for (int fl = 0; fl < files.Length; fl++)
            {
                request.KeepAlive = (files.Length != fl);
                stream = File.OpenRead(Path.Combine(dir, files[fl]));
                reqStream = request.GetRequestStream();
                buffer = new byte[4096 * 2];
                int nRead = 0;
                while ((nRead = stream.Read(buffer, 0, buffer.Length)) != 0)
                {
                    reqStream.Write(buffer, 0, nRead);
                }
                stream.Close();
                reqStream.Close();

                response = (FtpWebResponse)request.GetResponse();
                response.Close();
            }

解决方案

Although replying to an old post just thought it might help someone.

When you create your ftp url make sure you are not including the default directory for that login.

for example this was the path which I was specifying and i was getting the exception 553 FileName not allowed exception

ftp://myftpip/gold/central_p2/inbound/article_list/jobs/abc.txt

The login which i used had the default directory gold/central_p2.so the supplied url became invalid as it was trying to locate the whole path in the default directory.I amended my url string accordingly and was able to get rid of the exception.

my amended url looked like

ftp://myftpip/inbound/article_list/jobs/abc.txt

Thanks,

Sab

这篇关于无法连接到FTP:(553)不允许的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆