forked from robinrodricks/FluentFTP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Connect.cs
49 lines (35 loc) · 993 Bytes
/
Connect.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
48
49
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using FluentFTP;
namespace Examples {
internal static class ConnectExample {
public static void Connect() {
using (var conn = new FtpClient()) {
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
conn.Connect();
}
}
public static void ConnectAlt() {
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
conn.Connect();
}
}
public static async Task ConnectAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient()) {
conn.Host = "localhost";
conn.Credentials = new NetworkCredential("ftptest", "ftptest");
await conn.ConnectAsync(token);
}
}
public static async Task ConnectAsyncAlt() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);
}
}
}
}