用C#写的FTP访问FTP服务器代码出错,500命令出错。

最近在做FTP客户端测试,本地代码没问题。把代码放到与FTP服务器同一个局域网的电脑上,出错了,FTP服务器用Alfresco搭建的(好矫情的服务器),同样的代码,能访问ftp://IP,也能访问ftp://IP/Alfresco,但是访问到ftp://IP/Alfresco/xxx的时候就报错,500命令出错,关键是同样的代码。同时我用资源管理器打开创建文件夹都没问题,用cmd下访问文件夹也没有问题,有大神能解决吗?我贴一下代码

///

/// 获取当前目录下明细(包含文件和文件夹)

///

///

public string[] GetFilesDetailList()
{
string[] downloadFiles;
try
{
StringBuilder result = new StringBuilder();
string ui = ftpUristring + "/Alfresco/Intergration";
FtpWebRequest request = CreateFtpWebRequest(ui, WebRequestMethods.Ftp.ListDirectoryDetails);
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);

            string line = reader.ReadLine();

            while (line != null)
            {
                result.Append(line);
                result.Append("\n");
                line = reader.ReadLine();
            }
            result.Remove(result.ToString().LastIndexOf("\n"), 1);
            reader.Close();
            response.Close();
            return result.ToString().Split('\n');
        }
        catch (Exception ex)
        {
            downloadFiles = null;
            throw ex;
        }
    }  

看你这个函数是获取一个目录下所有的文件,一次性访问多个文件的时候加上 request.KeepAlive = false;试试, KeepAlive - 指定连接是应该关闭还是在请求完成之后关闭,默认为true。

我刚才调试通了,是路径不规范的问题。把这行代码写成:

string ui = ftpUristring + "//Alfresco//Intergration/";
(文件夹之间两个/斜杠,文件夹名后加一个/杠)

就进去了,哎,自己调试了四五天,终于解决了。。哎

windows就这样