forked from robinrodricks/FluentFTP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileExists.cs
36 lines (30 loc) · 947 Bytes
/
FileExists.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
using System;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using FluentFTP;
namespace Examples {
internal static class FileExistsExample {
public static void FileExists() {
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
conn.Connect();
// The last parameter forces FluentFTP to use LIST -a
// for getting a list of objects in the parent directory.
if (conn.FileExists("/full/or/relative/path")) {
// dome something
}
}
}
public static async Task FileExistsAsync() {
var token = new CancellationToken();
using (var conn = new FtpClient("127.0.0.1", "ftptest", "ftptest")) {
await conn.ConnectAsync(token);
// The last parameter forces FluentFTP to use LIST -a
// for getting a list of objects in the parent directory.
if (await conn.FileExistsAsync("/full/or/relative/path", token)) {
// dome something
}
}
}
}
}