<small id='Cb2DL'></small><noframes id='Cb2DL'>

  • <tfoot id='Cb2DL'></tfoot><legend id='Cb2DL'><style id='Cb2DL'><dir id='Cb2DL'><q id='Cb2DL'></q></dir></style></legend>
    <i id='Cb2DL'><tr id='Cb2DL'><dt id='Cb2DL'><q id='Cb2DL'><span id='Cb2DL'><b id='Cb2DL'><form id='Cb2DL'><ins id='Cb2DL'></ins><ul id='Cb2DL'></ul><sub id='Cb2DL'></sub></form><legend id='Cb2DL'></legend><bdo id='Cb2DL'><pre id='Cb2DL'><center id='Cb2DL'></center></pre></bdo></b><th id='Cb2DL'></th></span></q></dt></tr></i><div id='Cb2DL'><tfoot id='Cb2DL'></tfoot><dl id='Cb2DL'><fieldset id='Cb2DL'></fieldset></dl></div>

      • <bdo id='Cb2DL'></bdo><ul id='Cb2DL'></ul>

      1. FtpWebRequest 返回“550 文件不可用(例如,文件未找

        时间:2023-06-04

        <i id='f51fl'><tr id='f51fl'><dt id='f51fl'><q id='f51fl'><span id='f51fl'><b id='f51fl'><form id='f51fl'><ins id='f51fl'></ins><ul id='f51fl'></ul><sub id='f51fl'></sub></form><legend id='f51fl'></legend><bdo id='f51fl'><pre id='f51fl'><center id='f51fl'></center></pre></bdo></b><th id='f51fl'></th></span></q></dt></tr></i><div id='f51fl'><tfoot id='f51fl'></tfoot><dl id='f51fl'><fieldset id='f51fl'></fieldset></dl></div>

            <small id='f51fl'></small><noframes id='f51fl'>

              <bdo id='f51fl'></bdo><ul id='f51fl'></ul>
              <tfoot id='f51fl'></tfoot>

                  <tbody id='f51fl'></tbody>
              • <legend id='f51fl'><style id='f51fl'><dir id='f51fl'><q id='f51fl'></q></dir></style></legend>

                • 本文介绍了FtpWebRequest 返回“550 文件不可用(例如,文件未找到,无法访问)"对存在的目录使用 ListDirectoryDe​​tails 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个烦人的问题,阻止我在 FTP 中获取我需要的文件.此文件可能有不同的名称,因此我需要先访问该文件夹并列出其中的文件,然后直接向该文件发出请求.

                  我的问题是,例如,我可以在 Filezilla 中访问此文件,并且也完美地发现了该文件夹,但是当使用 FtpWebResponse 实例获取该文件夹时,出现错误 550

                  <块引用>

                  550 文件不可用(例如文件未找到,无法访问)

                  这里是代码:

                  FtpWebRequest wr = (FtpWebRequest)WebRequest.Create("ftp://ftp.dachser.com/data/edi/kunden/da46168958/out");wr.Method = WebRequestMethods.Ftp.ListDirectoryDe​​tails;wr.Credentials = new NetworkCredential(登录"、密码");FtpWebResponse 响应 = (FtpWebResponse)wr.GetResponse();流响应流 = response.GetResponseStream();StreamReader reader = new StreamReader(reponseStream);字符串名称 = reader.ReadToEnd();

                  <块引用>

                  FtpWebResponse 响应 = (FtpWebResponse)wr.GetResponse();

                  是抛出错误的那一行

                  PS:生产、测试​​和 FileZilla 在同一个域中,使用相同的互联网连接(如果有帮助)

                  感谢您的关注和反馈

                  FileZilla 日志:

                  来自我的程序的日志,红色圈出的错误与 FTP 错误无关

                  解决方案

                  FtpWebRequest 解释 URL 时,它不会将分隔主机名和路径的斜杠视为路径的一部分.然后将提取的路径按原样与 FTP CWD 命令一起使用.这意味着 FTP 服务器将相对于您的主目录解析路径.如果您的帐户未经过 chroot(客户端未将 home 视为根),则缺少前导斜杠会导致意外行为.

                  在您的情况下,您从 /remote/path 开始并使用 ftp://example.com/remote/path/ 之类的 URL,它将尝试更改到 remote/path,所以最终到 /remote/path/remote/path.这不是你想要的.

                  • 您必须使用主文件夹的相对路径.在您的情况下,这意味着使用没有任何路径的 URL.
                  • 或者使用绝对路径,需要在主机名后使用两个斜杠:ftp://example.com//remote/path/.

                  另请注意,文件夹的 URL 应以斜杠结尾:为什么 FtpWebRequest 会为此现有目录返回空流?

                  其他 550 问题见FtpWebRequest 返回错误 550 文件不可用

                  I have an annoying problem preventing me to get a file I need in an FTP. This file may have differents names so I need to access the folder first and list files inside to do a request directly to the file then.

                  My problem is that I can access this file in Filezilla for example, and perfectly discovers the folder as well, but when using an FtpWebResponse instance to get the folder, I have an error 550

                  550 File unavailable (e.g. file not found, no access)

                  here is the code :

                  FtpWebRequest wr = (FtpWebRequest)WebRequest.Create("ftp://ftp.dachser.com/data/edi/kunden/da46168958/out");
                  
                  wr.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
                  
                  wr.Credentials = new NetworkCredential("login", "password");
                  
                  FtpWebResponse response = (FtpWebResponse)wr.GetResponse();
                  
                  Stream reponseStream = response.GetResponseStream();
                  
                  StreamReader reader = new StreamReader(reponseStream);
                  
                  string names = reader.ReadToEnd();
                  

                  FtpWebResponse response = (FtpWebResponse)wr.GetResponse();

                  is the line throwing the error

                  PS: Production, tests and FileZilla are on the same domain, using the same internet connection (if it helps)

                  Thanks for your attention and feedback

                  The FileZilla logs:

                  Logs from my program, error circled in red isn't related to FTP error

                  解决方案

                  When FtpWebRequest interprets the URL, it does not consider the slash that separates the hostname and the path as a part of the path. The extracted path is then used with FTP CWD command as is. That means that the FTP server will resolve the path relatively to your home directory. If your account is not chrooted (the home is not seen as the root by the client), the lack of the leading slash leads to unexpected behaviour.

                  In your case, you start in /remote/path and with URL like ftp://example.com/remote/path/, it will try to change to remote/path, so ultimately to /remote/path/remote/path. That's not what you want.

                  • Either you must use a relative path to the home folder. What in your case means using an URL without any path.
                  • Or use an absolute path, for which you need to use two slashes after the hostname: ftp://example.com//remote/path/.

                  Also note that an URL to a folder should end with a slash: Why does FtpWebRequest return an empty stream for this existing directory?

                  For other 550 problems, see FtpWebRequest returns error 550 File unavailable

                  这篇关于FtpWebRequest 返回“550 文件不可用(例如,文件未找到,无法访问)"对存在的目录使用 ListDirectoryDe​​tails 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:为什么 FtpWebRequest 为这个现有目录返回一个空流 下一篇:获取“(553)文件名不允许"在 FTP 服务器上重命

                  相关文章

                  最新文章

                    <bdo id='koHZR'></bdo><ul id='koHZR'></ul>
                • <tfoot id='koHZR'></tfoot>

                  <i id='koHZR'><tr id='koHZR'><dt id='koHZR'><q id='koHZR'><span id='koHZR'><b id='koHZR'><form id='koHZR'><ins id='koHZR'></ins><ul id='koHZR'></ul><sub id='koHZR'></sub></form><legend id='koHZR'></legend><bdo id='koHZR'><pre id='koHZR'><center id='koHZR'></center></pre></bdo></b><th id='koHZR'></th></span></q></dt></tr></i><div id='koHZR'><tfoot id='koHZR'></tfoot><dl id='koHZR'><fieldset id='koHZR'></fieldset></dl></div>

                      <small id='koHZR'></small><noframes id='koHZR'>

                    1. <legend id='koHZR'><style id='koHZR'><dir id='koHZR'><q id='koHZR'></q></dir></style></legend>