简体   繁体   English

如何使用SharpSSH将文件移动到SFTP服务器

[英]How to Move a file to SFTP server using SharpSSH

need to move file from one folder to another on filezilla using Tamir.SharpSsh.Sftp. 需要使用Tamir.SharpSsh.Sftp在filezilla上将文件从一个文件夹移动到另一个文件夹。

    Tamir.SharpSsh.Sftp client = new Tamir.SharpSsh.Sftp(address, username, password);
    client.Connect();
    client.? // for move file from one folder to another 

Try this... 尝试这个...

Tamir.SharpSsh.Sftp client = new Tamir.SharpSsh.Sftp(address, username, password);
client.Connect();
if(client.Connected) {
    client.Rename("/source/path/file.zip", "/destination/path/file.zip");
} else {throw new ... }

On *nix OSes, move and rename are synonymous. 在* nix操作系统上,移动和重命名是同义词。 Sftp seems to have inherited the design. Sftp似乎继承了该设计。

Heres an extract from code i worked on a while ago 这是我前一段时间工作的代码的摘录

try{
Tamir.SharpSsh.Sftp secureFtp;
secureFtp = new Tamir.SharpSsh.Sftp(ServerPath, username, password);
Console.WriteLine("connecting");
secureFtp.Connect();
if(secureFtp.Connected)
{
Console.WriteLine("Connected");
secureFtp.Put(Targetpath_filename, DestinationPath_filename);
//Targetpath_filename = "C:\somepath\somefile.extension
//DestinationPath_filename = "/in/somefilename.extension" or whatever the ftp path is
}
else
{
Console.WriteLine("Error connecting");}
}
catch(Exception E)
{
Console.WriteLine(E.Message);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM