I need to verify that a unix folder exists, from my C# application using SharpSsh.
I thought of trying this:
SshExec.RunCommand("-d " + folder)
But the result is always '2' regardless if the folder is there or not. I could implement something using:
Sftp.GetFileList(folder)
But prefer not to because this folder may contain numerous files and It causes a delay while all of them are retrieved which is not elegant.
Any ideas?
Edit: I tried this:
string folder = "/foldername";
string result = sshExec.RunCommand("[ -d " + folder + "] && echo 'true' || echo 'false'");
if (result == "false")
throw new Exception("Directory " + foldername+ " + is not found.");
String 'result' is set as "false\n" even though the directory exists. If I skip the check I can work with the directory without problems.