forked from robinrodricks/FluentFTP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DownloadFile.cs
39 lines (28 loc) · 1.28 KB
/
DownloadFile.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
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using FluentFTP;
namespace Examples {
internal static class DownloadFileExample {
public static void DownloadFile() {
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
ftp.Connect();
// download a file and ensure the local directory is created
ftp.DownloadFile(@"D:\Github\FluentFTP\README.md", "/public_html/temp/README.md");
// download a file and ensure the local directory is created, verify the file after download
ftp.DownloadFile(@"D:\Github\FluentFTP\README.md", "/public_html/temp/README.md", FtpLocalExists.Overwrite, FtpVerify.Retry);
}
}
public static async Task DownloadFileAsync() {
var token = new CancellationToken();
using (var ftp = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
await ftp.ConnectAsync(token);
// download a file and ensure the local directory is created
await ftp.DownloadFileAsync(@"D:\Github\FluentFTP\README.md", "/public_html/temp/README.md");
// download a file and ensure the local directory is created, verify the file after download
await ftp.DownloadFileAsync(@"D:\Github\FluentFTP\README.md", "/public_html/temp/README.md", FtpLocalExists.Overwrite, FtpVerify.Retry);
}
}
}
}