开发者

Help Needed for parsing FTP files list in c#

I am using this code for getting list of all the files in directory

here webRequestUrl = something.com/directory/

FtpWebRequest fwrr = (FtpWebRequest)FtpWebRequest.Create(开发者_如何转开发new Uri("ftp://" + webRequestUrl));

fwrr.Credentials = new NetworkCredential(username, password);
fwrr.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
StreamReader srr = new StreamReader(fwrr.GetResponse().GetResponseStream());
string str = srr.ReadLine();
ArrayList strList = new ArrayList();
while (str != null)
{
  strList.Add(str);
  str = srr.ReadLine();
}

but I am not getting the list of files, but getting some HTML document type lines.

This ftp server is windows based while it is working fine in unix server.

Please help.

Thanks.


It works for me when the FTP on a internal machine and I do a ftp://192.168.0.155 - If I try that in IE I get the same HTML result like yours. I doubt if its happening because of the url. Can you try replacing the url with the IP address (just a wild guess). Even if you are getting HTML, you can strip the unnecessary part and parse the files.

I even tried with a ftp://sub.a.com/somefolder and it worked for me. It seems the browser wraps the HTML around the FTP response because I get different HTML when I opened the FTP site in IE and Chrome.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜