日期:2014-05-17  浏览次数:20402 次

通过ie代理访问ftp的问题
功能很简单,首先判断指定目录下某文件夹是否存在,如果存在则返回该文件夹下的所有文件名。
公司内部不能直接访问外网,要通过IE浏览器代理。
不设置FtpWebRequest.Proxy时报错:远程服务器返回错误:(502)错误的网关
把FtpWebRequest.Proxy设置为null时不报错,但获取到的中文名称为乱码。
主要代码如下:
     string path = "";
    string dir = "";
            FtpWebRequest reqFTP;
            reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(path));
            reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
            reqFTP.UseBinary = true;
            //reqFTP.Proxy = null;
            reqFTP.Credentials = new NetworkCredential("", "");
            FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
            StreamReader ftpStream = new StreamReader(response.GetResponseStream());

            List<string> files = new List<string>();
            string line = ftpStream.ReadLine();
            while (line != null)
            {
                files.Add(line);
                line = ftpStream.ReadLine();
            }

            ftpStream.Close();
            response.Close();
            return files.Contains(dir);

在向该ftp站点上传文件时,使用jquery.uploadify.v2.1同时上传多个文件时,只有第一个可以成功上传,其他的上传进度条也正常走完,没有报错,但ftp里面没有。
本人新手,欢迎指教,非常感谢
FTP 代理