-
-
Notifications
You must be signed in to change notification settings - Fork 659
/
DownloadManyFiles.cs
47 lines (38 loc) · 1.2 KB
/
DownloadManyFiles.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using FluentFTP;
namespace Examples {
internal static class DownloadFilesExample {
public static void DownloadFiles() {
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
ftp.Connect();
// download many files, skip if they already exist on disk
ftp.DownloadFiles(@"D:\Drivers\test\",
new[] {
@"/public_html/temp/file0.exe",
@"/public_html/temp/file1.exe",
@"/public_html/temp/file2.exe",
@"/public_html/temp/file3.exe",
@"/public_html/temp/file4.exe"
}, FtpLocalExists.Skip);
}
}
public static async Task DownloadFilesAsync() {
var token = new CancellationToken();
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.Connect(token);
// download many files, skip if they already exist on disk
await ftp.DownloadFiles(@"D:\Drivers\test\",
new[] {
@"/public_html/temp/file0.exe",
@"/public_html/temp/file1.exe",
@"/public_html/temp/file2.exe",
@"/public_html/temp/file3.exe",
@"/public_html/temp/file4.exe"
}, FtpLocalExists.Skip, token: token);
}
}
}
}