期待是获取到125的响应 请求响应的差异在哪,怎么去解决响应码是150的情况
用list协议去获取文件ftp路径下的文件和文件夹。请求ftp服务器(本地、局域网服务器、外网ftp服务器3种)的返回码有的是125(DataAlreadyOpen)(能正常取到含有<DIR>的字符串:“06-24-20 09:50AM <DIR> Backup”),有的是150(OpeningData)(获取的字符串: “drwxr-xr-x 1 ftp ftp 0 Mar 30 2020 InputErpSql_V2.3.0.200316_XM”)
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
private FtpWebResponse callFtp(string method)
{
string uri = string.Format("ftp://{0}:{1}{2}", this.IpAddr, this.Port, this.RelatePath);
FtpWebRequest request;
request = (FtpWebRequest)FtpWebRequest.Create(uri);
request.UseBinary = true;
request.UsePassive = true;
request.Credentials = new NetworkCredential(UserName, Password);
request.KeepAlive = false;
request.Method = method;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
return response;
}