Hi,
I'm tring move zip files from one directory to another directory in the same server using by C#.
Despite app doesn't throw any erros, I can move those file, . I've red many articles but I haven't
found clear answer so far. Therefore I'm asking you for help. Below is a code:
try
{
SessionOptions sessionOptions = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "xxxxxxxxx.xxxxxxxxx.xxx.xx",
UserName = "xxxxxxxxx",
Password= "xxxxxxxxx",
SshHostKeyFingerprint = "ssh-rsa xxx"
};
string fileName = "aaa.zip";
string remotePath = "/sftp/xxxx/xxxxxx/Test" + "/" + fileName;
//string remotePath1 = "/sftp/xxxx/xxxxxx/Test/Archive"; -> doesn't work
//string remotePath1 = "/sftp/xxxx/xxxxxx/Test/Archive" + "/"; -> doesn't work
string remotePath1 = "/sftp/xxxx/xxxxxx/Test/Archive" + "/" + fileName; // -> doesn't work
using (Session session = new Session())
{
session.Open(sessionOptions);
Console.WriteLine("\nFrom here:\n{0}\nto here:\n{1}\n", remotePath, remotePath1);
if (session.FileExists(remotePath))
session.MoveFile(remotePath, remotePath1);
}
}
catch (Exception e)
{
Console.WriteLine("Error: {0}", e);
return;
}
I guess It might be sth wrong with remotePath1, and I tred diferent combination of the remotePath1. Unfortunately, all of them failed. May be you have got better ideas?