-
-
Notifications
You must be signed in to change notification settings - Fork 657
/
Copy pathDownloadDirectory.cs
43 lines (30 loc) · 1.24 KB
/
DownloadDirectory.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
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using FluentFTP;
using FluentFTP.Rules;
namespace Examples {
internal static class DownloadDirectoryExample {
public static void DownloadDirectory() {
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
ftp.Connect();
// download a folder and all its files
ftp.DownloadDirectory(@"C:\website\logs\", @"/public_html/logs", FtpFolderSyncMode.Update);
// download a folder and all its files, and delete extra files on disk
ftp.DownloadDirectory(@"C:\website\dailybackup\", @"/public_html/", FtpFolderSyncMode.Mirror);
}
}
public static async Task DownloadDirectoryAsync() {
var token = new CancellationToken();
using (var ftp = new AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.Connect(token);
// download a folder and all its files
await ftp.DownloadDirectory(@"C:\website\logs\", @"/public_html/logs", FtpFolderSyncMode.Update, token: token);
// download a folder and all its files, and delete extra files on disk
await ftp.DownloadDirectory(@"C:\website\dailybackup\", @"/public_html/", FtpFolderSyncMode.Mirror, token: token);
}
}
}
}