[英]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/
... / public_html / Folder1 / name1 / 到 ... / public_html / Folder1 / name2 /
I am using the WinSCP .NET library for this. 我为此使用WinSCP .NET库。 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.
提前致谢。
WinSCP .NET assembly does not have an API for this. WinSCP .NET程序集对此没有API。
Even if it had, most FTP/SFTP servers do not support that anyway: 即使有,大多数FTP / SFTP服务器也不支持该功能:
You didn't specify what protocol are you using, though. 不过,您没有指定要使用的协议。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.