The following code will download the file named file.txt
from the SFTP remote server to the local machine.
sftp.Get("/usr/mine/file.txt" , "C:/Folder/");
What I want to do is check if the file file.txt
exist on the remote server or not. How can I do this check?
I am using SharpSSH
This should do the trick.
using (var sftp = new SftpClient(host, username, password))
{
try
{
sftp.Connect();
MessageBox.Show(sftp.Exists(remoteDirectory).ToString());
}
catch (Exception Sftpex)
{
MessageBox.Show(Sftpex.ToString());
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With