FtpWebRequest throw exception on Success RRS feed

  • Question

  • Hello,

    I am attempting to list a folder on a FTP server.

    When I list a single folder  "myserver.whatever.com/folder"  It succeeds.

    When I list a second level folder, "myserver.whatever.com/folder/folder1"  It fails.

    This code:

    request = (FtpWebRequest)WebRequest.Create(m_server + folder);
    request.ClientCertificates = m_certificates;
    request.Credentials = new NetworkCredential(m_userName.Normalize(), password.Normalize() );
    request.EnableSsl = true;
    request.Method = WebRequestMethods.Ftp.ListDirectory;
    response = (FtpWebResponse)request.GetResponse();
    Stream responseStream = response.GetResponseStream();
    StreamReader reader = new StreamReader(responseStream);

    Throws this exception:

    The remote server returned an error: 150 Opening data connection. List started\r\n

    You should know that a code of 150 is NOT AN ERROR.  Why would this be throw an exception on something that is not an error?


    Wednesday, December 23, 2020 3:48 PM