-1

I need list ftp site directory with username and password, and I can access it in FileZilla.

The Directory structure in FileZilla is like below,

/ FtpDir Input Input Archive
Output Output Archive

However, when accessing it in FtpWebRequest class in C#, it gives exception "The remote server returned an error: (550) File unavailable (e.g., file not found, no access)". The code is,

            FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://ftp.xx.x.xx.xx/FtpDir/Input/");
            request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
            request.Credentials = new NetworkCredential(username, password);

I have accessed another Ftp site successfully, the uri is like ftp://ftp.somecompany.com/FtpDir/ and I can access ftp://ftp.somecompany.com/FtpDir/ from file explorer as well. But I cannot access ftp://ftp.xx.x.xx.xx/FtpDir/Input/ from file explorer.

What is the problem?

Thanks

psbookmark
  • 105
  • 1
  • 12

1 Answers1

0

request.UsePassive = false; solved the problem.

psbookmark
  • 105
  • 1
  • 12