public void Execute(string ftpUri, string path = null, string username = null, string password = null) { Console.WriteLine("File upload beginning..."); if (!File.Exists(path)) { Console.WriteLine($"{ftpUri} upload error -> {path} not found."); return; } using (var ftp = new FileTransferProtocol(ftpUri, path, username, password)) { try { ftp.UploadFile(); Console.Write(ftp.RequestStatus); } catch (Exception exception) { Console.WriteLine($"{ftpUri} upload error -> {exception.Message}"); } } }
public void CheckUploadFile() { string ftp_uri = $"{Config.Server_Address}/uploaded_zip_file.zip"; const string path = "downloaded_zip_file.zip"; try { using (var ftp = new FileTransferProtocol(ftp_uri, path, Config.Username, Config.Password)) { Assert.That(File.Exists(path)); ftp.UploadFile(); Assert.That(ftp.RequestStatusCode == FtpStatusCode.ClosingData); } } catch (Exception exception) { if (exception is WebException) { Assert.Fail(exception.Message); } } }