Connect To FTP(Linux) in C#: 'Operation failed

2019-08-28 12:35发布

问题:

I want Connect to the Ftp in c#.

 public static byte[] DownloadFile(int timeout, string ftpServer, string filePath, string username, string password)
    {
     var client = new FtpClient();
        client.Connect(timeout, ftpServer, 21);
        client.Login(timeout, username, password);

        List<FtpItem> ftpItems = client.GetDirectoryList(timeout, directoryPath).ToList();
        return ftpItems;
    }

Sucessfull login but when i want to get file

        List<FtpItem> ftpItems = client.GetDirectoryList(timeout, directoryPath).ToList();

I get this error:Operation failed.

and this response:425 Failed to establish connection.

标签: c# ftp