代码拉取完成,页面将自动刷新
Imports System
Imports System.Net
Imports System.Threading
Imports System.Threading.Tasks
Imports FluentFTP
Namespace Examples
Friend Module GetHashExample
'-----------------------------------------------------------------------------------------
' 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 GetHash()
Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest")
conn.Connect()
If conn.HashAlgorithms <> FtpHashAlgorithm.NONE Then
Dim hash As FtpHash
hash = conn.GetHash("/path/to/remote/somefile.ext")
If hash.Verify("/path/to/local/somefile.ext") Then
Console.WriteLine("The computed hashes match!")
End If
If conn.HashAlgorithms.HasFlag(FtpHashAlgorithm.MD5) Then
conn.SetHashAlgorithm(FtpHashAlgorithm.MD5)
hash = conn.GetHash("/path/to/remote/somefile.ext")
If hash.Verify("/path/to/local/somefile.ext") Then
Console.WriteLine("The computed hashes match!")
End If
End If
End If
End Using
End Sub
Async Function GetHashAsync() As Task
Dim token = New CancellationToken()
Using conn = New FtpClient("127.0.0.1", "ftptest", "ftptest")
Await conn.ConnectAsync(token)
If conn.HashAlgorithms <> FtpHashAlgorithm.NONE Then
Dim hash As FtpHash
hash = Await conn.GetHashAsync("/path/to/remote/somefile.ext", token)
If hash.Verify("/path/to/local/somefile.ext") Then
Console.WriteLine("The computed hashes match!")
End If
If conn.HashAlgorithms.HasFlag(FtpHashAlgorithm.MD5) Then
conn.SetHashAlgorithm(FtpHashAlgorithm.MD5)
hash = Await conn.GetHashAsync("/path/to/remote/somefile.ext", token)
If hash.Verify("/path/to/local/somefile.ext") Then
Console.WriteLine("The computed hashes match!")
End If
End If
End If
End Using
End Function
End Module
End Namespace
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。