After seeing a long-winded version on the forums about how to generate a MD5# for a file I thought I'd post how to do this here...
vb.net Code:
Private Function CalcMD5(ByVal File As String) As String
Dim f = New IO.FileStream(File, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read, 4096)
Dim md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
Return Join((From xItem In md5.ComputeHash(f) Select xItem.ToString("X2")).ToArray, "")
End Function
Also you could use the following to calculate the older (and slower) SHA#:
vb.net Code:
Private Function CalcSHA(ByVal File As String) As String
Dim f = New IO.FileStream(File, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read, 4096)
Dim sha1 As New System.Security.Cryptography.SHA1CryptoServiceProvider
Return Join((From xItem In sha1.ComputeHash(f) Select xItem.ToString("X2")).ToArray, "")
End Function
Hope this helps some people ...
Also please provide feedback and say thanks if this helped you
Kris