2

need to move file from one folder to another on filezilla using Tamir.SharpSsh.Sftp.

    Tamir.SharpSsh.Sftp client = new Tamir.SharpSsh.Sftp(address, username, password);
    client.Connect();
    client.? // for move file from one folder to another 
Aditya
  • 44
  • 1
  • 12
  • It'd help if you tell us what you've tried, what specific bit you're stuck with, and what you've tried to do to solve those problems – aberna Feb 23 '15 at 08:16
  • 1
    possible duplicate of [Upload to FTP server C# using Tamir.SharpSSH](http://stackoverflow.com/questions/25178410/upload-to-ftp-server-c-sharp-using-tamir-sharpssh) – Basic Feb 23 '15 at 08:26
  • your provided link shows upload or download from or to local machine ... i need to move file one folder to another on server . – Aditya Feb 23 '15 at 08:30

2 Answers2

4

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. Sftp seems to have inherited the design.

Basic
  • 26,321
  • 24
  • 115
  • 201
0

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);
}
Jonny
  • 401
  • 2
  • 11
  • thanks but secureFtp.Put(Targetpath_filename, DestinationPath_filename); upload file from loacal . i need to move file from one folder to anothernot from local . please can you provide some code or link for delete file – Aditya Feb 23 '15 at 09:05
  • Then i recommend that you change the target path to the path on the server... Else you need to download the file onto your machine and then upload it again. If the permissions are set right then you should be able to just move it as i suggested. – Jonny Feb 23 '15 at 10:26
  • if i give Targetpath_filename = server file add then give the message comes the file not found ? – Aditya Feb 23 '15 at 11:27
  • how can i replace Targetpath_filename = "C:\somepath\somefile.extension to a server address . – Aditya Feb 23 '15 at 11:52