0

以下代码在我自己的机器(Win7 ISS7)上运行良好,但是当我将其移动到数据中心上运行 IIS8 的虚拟服务器时,我得到返回代码 150(openingdata)。我可以通过此服务器上的 IE 访问 ftp 站点。这是编码问题还是配置。任何帮助是极大的赞赏。

我也尝试过更改 UsePassive、UseBinary、无缓存、无效并将其放置在 azure 机器上但无济于事。

private List<string> Browse()
{
  // Get the object used to communicate with the server.
  FtpWebRequest request = (FtpWebRequest)WebRequest.Create(m_Url);

  request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
  result.Add("Timeout = " + request.Timeout.ToString());
  // This example assumes the FTP site uses anonymous logon.
  request.Credentials = new NetworkCredential(m_Username, m_Password);
  request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);

  if (m_Proxy != null)
  {
    request.Proxy = m_Proxy;
  }


  bool started = false;
  using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
  {
    Stream responseStream = response.GetResponseStream();

    using (StreamReader reader = new StreamReader(responseStream))
    {
      string line = reader.ReadLine();
      while (line != null)
      {
        result.Add(line);
        line = reader.ReadLine();
      }
    }
  }
  return result;
}
4

1 回答 1

0

原来是程序错误

FtpWebRequest 请求 = (FtpWebRequest)WebRequest.Create(m_Url);

本来应该

FtpWebRequest 请求 = (FtpWebRequest)* Ftp *WebRequest.Create(m_Url);

于 2013-11-13T12:01:18.777 回答