我的代码是网上用的很多的类库,如果用本机上的IIS中的FTP服务, 在用NLST列出文件时,会报"226 Transfer complete."程序就退出了. 如果在本机用Serv-U服务器有时候正常, 有时候会报"226 Transfer complete.". 但是访问其他网络上的机器就没有这样的问题. 请大家帮帮忙看看!!
代码很长, 如果大家认为有必要, 我就把代码发上来.
代码很长, 如果大家认为有必要, 我就把代码发上来.
是不是这个动作执行完了的下一个动作导致它退出了?
/// Return a string array containing the remote directory's
///file list.
///
///
///
public string[] getFileList(string mask)
{ if(!logined)
{
login();
} Socket cSocket = createDataSocket(); sendCommand("NLST " + mask);
////出问题的地方, 这个时候reply的值是"226 Transfer complete", retValue的值是"226", 下面的语句就导致程序抛出错误并退出了. if(!(retValue == 150 || retValue == 125))
{
throw new IOException(reply.Substring(4));
} mes = ""; while(true)
{ int bytes = cSocket.Receive(buffer, buffer.Length, 0);
mes += ASCII.GetString(buffer, 0, bytes); if(bytes < buffer.Length)
{
break;
}
} char[] seperator = {'\n'};
string[] mess = mes.Split(seperator); cSocket.Close(); readReply(); if(retValue != 226)
{
throw new IOException(reply.Substring(4));
}
return mess; }