Search code examples
c#.netwinformswinscpwinscp-net

How to copy things from one remote directory to another in the same server using WinSCP .NET assembly in C#


Is there a way to copy files from one remote directory to another for example, from

.../public_html/Folder1/name1/ to .../public_html/Folder1/name2/

I am using the WinSCP .NET library for this. I have tried to look everywhere on the internet for a solution to this but can't seem to find one. The only solution that I could come up with is to download the files to a temp local location and upload them again to the new remote location and I didn't want to do that because it would take a lot longer than just to copy them in the remote server and then after I would have delete the temp folder, which would also take time. I don't want my program to be very slow as it is a bit slow already when uploading the files to a remote location. I have seen that you can move/rename folders/files from remote location to another by doing something like this:

session.Open(sessionOptions);
session.MoveFile(".../public_html/Folder1/name1/", ".../public_html/Folder1/name2/");

How do you copy files in the server. If anyone has a better solution then please say as it would be a great help. Thanks in advance.


Solution

  • WinSCP .NET assembly does not have an API for this.

    Even if it had, most FTP/SFTP servers do not support that anyway:

    You didn't specify what protocol are you using, though.