如何下载 [英] How to download

查看:48
本文介绍了如何下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C#

推荐答案

从SFTP服务器下载文件您可以使用 ComponentPro [ ^ ] 。以下代码演示了:



You can use for this purpose ComponentPro[^]. The following code demonstrates that:

using ComponentPro.Net;
using ComponentPro.IO;

...

// Create a new instance.
Sftp client = new Sftp();

// Connect to the SFTP server.
client.Connect("myserver");

// Authenticate.
client.Authenticate("userName", "password");

// ...

// Get all directories, subdirectories, and files from remote folder '/myfolder' to 'c:\myfolder'.
client.DownloadFiles("/myfolder", "c:\\myfolder");

// Get all directories, subdirectories, and files that match the specified search pattern from remote folder '/myfolder2' to 'c:\myfolder2'.
client.DownloadFiles("/myfolder2", "c:\\myfolder2", "*.cs");

// or you can simply put wildcard masks in the source path, our component will automatically parse it.
// download all *.css files from remote folder '/myfolder2' to local folder 'c:\myfolder2'.
client.DownloadFiles("/myfolder2/*.css", "c:\\myfolder2");

// Download *.cs and *.vb files from remote folder '/myfolder2' to local folder 'c:\myfolder2'.
client.DownloadFiles("/myfolder2/*.cs;*.vb", "c:\\myfolder2");

// Get files in the folder '/myfolder2' only.
TransferOptions opt = new TransferOptions(true, RecursionMode.None, false, (SearchCondition)null, FileExistsResolveAction.Overwrite, SymlinksResolveAction.Skip);
client.DownloadFiles("/myfolder2", "c:\\myfolder2", opt);

// ...

// Disconnect.
client.Disconnect();







有关更多示例,请参阅:

http://www.componentpro.com/sftp/ [ ^ ]


查看此链接,可以帮助您



http://www.sftp-net.com/ [ ^ ]
Check this link, may help you

http://www.sftp-net.com/[^]


这篇关于如何下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆