1

我有 6 个文件要从 Windows 复制到 Linux:input.dat、image1.tif、image2.tif、image3.tif、image4.tif、image5.tif

我正在使用 SharpSSH,现在我知道如何复制单个文件,但我的问题是无论如何我可以使用SharpSSH 复制多个文件,而不是一个一个地复制它们?

这是我复制一个文件的代码:

Sftp sshFTP;
string localPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\input.dat";
string remotePath = "/home/mowglin/working_directory";
this.sshFTP.Put(localPath, remotePath);

现在这工作正常,它将 input.dat 文件复制到 Linux,但我又如何发送或放置多个文件?

4

1 回答 1

0

您可以使用 directoryinfo 和 foreach 循环。

 DirectoryInfo d  = new DirectoeyInfo( directory where you get your files)
 FileInfo[] Files = d.GetFiles("*");

foreach(FileInfo file in Files)
{
    //put your code here
    //your remote path should be "/home/mowglin/working_directoey/" + file.name;
}
于 2014-07-14T01:02:22.503 回答