简体   繁体   English

如何使用C#中的WinSCP .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/ ... / 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.

相关问题 如何使用带有C#和WinSCP的模式获取远程目录的文件 - How to get the files of remote directory using a pattern with C# and WinSCP 如何使用C#和WinSCP从远程目录中删除“。”和“..”文件 - How to remove “.” and “..” files from remote directory with C# and WinSCP C#WinSCP .NET程序集从最新目录下载最新文件 - C# WinSCP .NET assembly Download the latest file from the latest directory 使用C#中的cmd将文件从一个目录复制到另一个目录 - Copy file from one directory to another using cmd in C# 使用WinSCP .NET程序集提取tarball C# - Extracting tarball C# using WinSCP .NET Assembly C# WinSCP .NET 程序集:如何异步上传多个文件 - C# WinSCP .NET assembly: How to upload multiple files asynchronously 如何使用 WinSCP 和 C# 将树视图的节点添加为远程目录中的文件夹 - How could I add nodes of a treeview as folders from a remote directory with WinSCP and C# 如何使用密码或SSH指纹WinSCP C#.NET程序集进行SFTP身份验证 - How to SFTP authenticate using password or SSH fingerprint WinSCP C# .NET assembly 使用c#将数据库从一台服务器复制到另一台 - Copy database from one server to another using c# 使用c#可靠地将文件从一台服务器复制到另一台 - Reliably copy files from one server to another using c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM