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

C# 如何使用SharpSSH将文件移动到SFTP服务器,c#,asp.net,net-sftp,C#,Asp.net,Net 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{ Tamir.Sha

需要使用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{
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);
}
试试这个

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 ... }

在*nix操作系统上,移动和重命名是同义词。Sftp似乎继承了这一设计。

如果您告诉我们您尝试了什么,您遇到了什么具体问题,以及您尝试了什么来解决这些问题,这会有所帮助。您提供的链接可能会重复显示从本地计算机上传或下载或下载到本地计算机。。。我需要将文件从服务器上的一个文件夹移动到另一个文件夹。谢谢,但请使用secureFtp.Put(Targetpath_filename,DestinationPath_filename);从loacal上传文件。我需要将文件从一个文件夹移动到另一个文件夹,而不是从本地文件夹。请提供一些删除文件的代码或链接,然后我建议您将目标路径更改为服务器上的路径。。。否则,您需要将文件下载到计算机上,然后再次上载。如果权限设置正确,那么您应该能够按照我的建议移动它。如果我给Targetpath\u filename=server file add,那么给消息是找不到文件?如何将Targetpath\u filename=“C:\somepath\somefile.extension替换为服务器地址。