-
-
Notifications
You must be signed in to change notification settings - Fork 656
/
GetChecksum.vb
51 lines (40 loc) · 1.49 KB
/
GetChecksum.vb
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
50
51
Imports System
Imports System.Net
Imports System.Threading
Imports System.Threading.Tasks
Imports FluentFTP
Namespace Examples
Module GetChecksumExample
'-----------------------------------------------------------------------------------------
' NOTE! GetChecksum automatically uses the first available hash algorithm on the server,
' And it should be used as far as possible instead of GetHash, GetMD5, GetSHA256...
'-----------------------------------------------------------------------------------------
Sub GetChecksum()
Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest")
conn.Connect()
' Get a hash checksum for the file
Dim hash As FtpHash = conn.GetChecksum("/path/to/remote/file")
' Make sure it returned a valid hash object
If hash.IsValid Then
If hash.Verify("/some/local/file") Then
Console.WriteLine("The checksum's match!")
End If
End If
End Using
End Sub
Async Function GetChecksumAsync() As Task
Dim token = New CancellationToken()
Using conn = New AsyncFtpClient("127.0.0.1", "ftptest", "ftptest")
Await conn.Connect(token)
' Get a hash checksum for the file
Dim hash As FtpHash = Await conn.GetChecksum("/path/to/remote/file", FtpHashAlgorithm.NONE, token)
' Make sure it returned a valid hash object
If hash.IsValid Then
If hash.Verify("/some/local/file") Then
Console.WriteLine("The checksum's match!")
End If
End If
End Using
End Function
End Module
End Namespace