我需要通过 ftp 从旧的 AS/400 服务器下载一些文件。我的代码看起来或多或少像:
FtpWebRequest _request = (FtpWebRequest)WebRequest.Create("ftp://ftpaddress/FOO.CSV");
_request.Credentials = new NetworkCredential(_ftpUsername, _ftpPassword);
_request.Method = WebRequestMethods.Ftp.DownloadFile;
FtpWebResponse response = (FtpWebResponse)_request.GetResponse();
但是,抛出异常并显示消息:
501 Character (/) not allowed in object name.
我猜 AS400 使用与/不同的路径分隔符,但我不知道如何以 (1) FtpWebRequest 接受和 (2) AS400 理解的方式来表达 uri。
还有其他人碰到过这个吗?
请您参考如下方法:
根据 this page , fwd slash 是路径分隔符:
The forward slash is the separator character for paths sent to the FTP server.
A similar conversation在 Microsoft 的论坛(2005 时代)上显示它是 FtpWebRequest 中的错误:
Currently FtpWebRequest does not support quote and I cannot think of a way you'll be able to overide the method without exposing our code Mariya Atanasova [NCL]MSFT, Moderator, Nov 2005
尝试更新到最新版本或尝试不同的库; MS 论坛线程有几个。
