Guest User

Untitled

a guest
Sep 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.11 KB | None | 0 0
  1.  If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
  2.             Try
  3.                 myStream = openFileDialog1.OpenFile()
  4.                 If (myStream IsNot Nothing) Then
  5.                     Dim data(myStream.Length) As Byte
  6.                     md5.ComputeHash(data, 0, myStream.Length)
  7.                     Dim hash As Byte() = md5.Hash
  8.                     Dim buff As StringBuilder = New StringBuilder
  9.                     Dim hashByte As Byte
  10.                     For Each hashByte In hash
  11.                         buff.Append(String.Format("{0:X1}", hashByte))
  12.                     Next
  13.  
  14.                     md5checksum = buff.ToString()
  15.                     MessageBox.Show(md5checksum)
  16.  
  17.  
  18.                 End If
  19.             Catch Ex As Exception
  20.                 MessageBox.Show("Cannot read file from disk. Original error: " & Ex.Message)
  21.             Finally
  22.                 ' Check this again, since we need to make sure we didn't throw an exception on open.
  23.                 If (myStream IsNot Nothing) Then
  24.                     myStream.Close()
  25.                 End If
  26.             End Try
Add Comment
Please, Sign In to add comment