无法使用C#SSH.NET更改目录
当我使用SSH.NET库连接到服务器时,默认文件夹是/ mif / stud3 / 2014 / rira1874.当我执行
res = ssh.CreateCommand("cd existingFolder").Execute();
Console.WriteLine(res);
它仍然保留在默认连接文件夹中.这有什么不对?
完整代码:
public void ConnectWithPassword(string username, string password, string domain, int port)
{
bool i = true;
using (var ssh = new SshClient(CreatePasswordConnectionInfo(username, password, domain)))
{
try
{
ssh.Connect();
if (ssh.IsConnected)
{
while(i == true)
{
string res = Regex.Replace(ssh.CreateCommand("pwd").Execute(), @"\r\n?|\n", "");
Console.Write(res + ": ");
res = ssh.CreateCommand(Console.ReadLine()).Execute();
Console.WriteLine(res);
}
}
else {
Console.WriteLine("Not connected");
}
ssh.Disconnect();
}
catch (Exception e)
{
Console.WriteLine("Exception caught: {0}", e);
}
}
}