Want to use C# (FtpWebResponse) to read file list from FTP, but it returns HTML

前提是你 提交于 2019-11-28 12:40:17

Could it be a web proxy interfering? Try to get around the proxy by using the following:

reqFTP.Proxy = GlobalProxySelection.GetEmptyWebProxy();

This is the result of using FtpWebRequest through an HTTP Proxy. The file listing gets pretty printed with HTML tags which have <A> hyperlinks to the individual files in the listing.

If you can't bypass the proxy, in our case it was possible to scrape the section with the file contents out of an enclosing <PRE> element, load it into an XmlDocument, and pull the file list out through .SelectNodes("//A/text()")

Bat_Programmer

I found the solution: the default proxy was enabled unexpectedly

I now have to disable it specifically using a config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <system.net>
    <defaultProxy enabled="false" useDefaultCredentials="true"/>
  </system.net>
</configuration>

In fact, it is really a .NET issue!

YouneS

FTP Requires PassiveMode to download, upload...

Instead, try to use:

reqFTP.UsePassive = true;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!