public bool CheckDirectory(BaseFtp srv) { using (var sftp = new SftpClient(srv.Host, srv.Port, srv.Username, srv.Password)) { sftp.Connect(); return(IsEmpty(sftp, srv.RemoteDirectory)); } }
public void Download(BaseFtp srv) { using (var sftp = new SftpClient(srv.Host, srv.Port, srv.Username, srv.Password)) { sftp.Connect(); DownloadDirectory(sftp, sftp.WorkingDirectory, srv.LocalDirectory); } }
public void Connect(BaseFtp srv) { using (var client = new SftpClient(srv.Host, srv.Port, srv.Username, srv.Password)) { client.KeepAliveInterval = TimeSpan.FromHours(1); client.Connect(); System.Diagnostics.Debug.WriteLine("Successful!"); } }
public void Connect(BaseFtp srv) { using (var client = new FtpClient()) { client.Host = srv.Host; client.Credentials = new NetworkCredential(srv.Username, srv.Password); //TODO user input client.EncryptionMode = FtpEncryptionMode.Explicit; client.ValidateCertificate += OnValidateCertificate; //client.SocketKeepAlive = true; client.Connect(); } }
public bool CheckDirectory(BaseFtp srv) { using (FtpClient client = new FtpClient()) { client.Host = srv.Host; client.Credentials = new NetworkCredential(srv.Username, srv.Password); //TODO user input client.EncryptionMode = FtpEncryptionMode.Explicit; client.ValidateCertificate += OnValidateCertificate; //client.SocketKeepAlive = true; client.Connect(); return(IsEmpty(client, srv.RemoteDirectory)); } }
public void Download(BaseFtp srv) { using (FtpClient client = new FtpClient()) { client.Host = srv.Host; client.Credentials = new NetworkCredential(srv.Username, srv.Password); //TODO user input client.EncryptionMode = FtpEncryptionMode.Explicit; client.ValidateCertificate += OnValidateCertificate; //client.SocketKeepAlive = true; client.Connect(); DownloadDirectory(client, srv.RemoteDirectory, srv.LocalDirectory); } }
private void ButtonPlay_Click(object sender, EventArgs e) { if (IsConnectedToInternet() == false) { MessageBox.Show("Not connected to internet", "TMF ftp"); return; } if (string.IsNullOrEmpty(TextBoxHost.Text) || string.IsNullOrEmpty(TextBoxUsername.Text) || string.IsNullOrEmpty(TextBoxPassword.Text) || string.IsNullOrEmpty(TextBoxPort.Text) || string.IsNullOrEmpty(TextBoxRemote.Text) || string.IsNullOrEmpty(TextBoxDestination.Text) || string.IsNullOrEmpty(ComboBoxConnectionType.Text) ) { MessageBox.Show("Could not connect, please check server info.", "TMF ftp"); return; } _baseFtp = new BaseFtp() { Host = TextBoxHost.Text, Username = TextBoxUsername.Text, Password = TextBoxPassword.Text, Port = Convert.ToInt32(TextBoxPort.Text), Type = ComboBoxConnectionType.SelectedText, Auto = CheckBoxAuto.Checked, RemoteDirectory = TextBoxRemote.Text, LocalDirectory = TextBoxDestination.Text }; if (ComboBoxConnectionType.Text == "FTPS") { Console.WriteLine("Connecting..."); GetFTPSRemoteDirectory(); } else if (ComboBoxConnectionType.Text == "SFTP") { Console.WriteLine("Connecting..."); Thread.Sleep(2000);//LOL Console.WriteLine("Try to download"); } }