forked from robinrodricks/FluentFTP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGetChecksum.cs
32 lines (29 loc) · 1.26 KB
/
GetChecksum.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
using System;
using System.Net;
using FluentFTP;
namespace Examples {
public static class GetChecksumExample {
public static void GetChceksumExample() {
FtpHash hash = null;
using (FtpClient cl = new FtpClient()) {
cl.Credentials = new NetworkCredential("user", "pass");
cl.Host = "some.ftpserver.on.the.internet.com";
hash = cl.GetChecksum("/path/to/remote/file");
// Make sure it returned a, to the best of our knowledge, valid
// hash object. The commands for retrieving checksums are
// non-standard extensions to the protocol so we have to
// presume that the response was in a format understood by
// FluentFTP and parsed correctly.
//
// In addition, there is no built-in support for verifying
// CRC hashes. You will need to write you own or use a
// third-party solution.
if (hash.IsValid && hash.Algorithm != FtpHashAlgorithm.CRC) {
if (hash.Verify("/some/local/file")) {
Console.WriteLine("The checksum's match!");
}
}
}
}
}
}