public void CheckListDirectory() { string ftp_uri = $"{Config.Server_Address}/"; try { using (var ftp = new FileTransferProtocol(ftp_uri, null, Config.Username, Config.Password)) { if (ftp.UpdateDirectoryList()) { Assert.That(ftp.RequestStatusCode == FtpStatusCode.OpeningData || ftp.RequestStatusCode == FtpStatusCode.DataAlreadyOpen); } else { throw new ArgumentException("Retrieved stream is invalid."); } } } catch (Exception exception) { if (exception is WebException) { Assert.Fail(exception.Message); } } }
public void Execute(string ftpUri, string path = null, string username = null, string password = null) { Console.WriteLine("Listing directory..."); try { using (var ftp = new FileTransferProtocol(ftpUri, path, username, password)) { if (ftp.UpdateDirectoryList()) { Console.WriteLine(ftp.Directory); } else { Console.Write(ftp.RequestStatus); } } } catch (Exception exception) { Console.WriteLine($"{ftpUri} list directory error -> {exception.Message}"); } }