Revision: 20564
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 19, 2009 01:15 by wearetherock
Initial Code
public static string GetMD5Hash(string pathName) { string strResult = ""; string strHashData = ""; byte[] arrbytHashValue; System.IO.FileStream oFileStream = null; System.Security.Cryptography.MD5CryptoServiceProvider oMD5Hasher= new System.Security.Cryptography.MD5CryptoServiceProvider(); try { oFileStream = GetFileStream(pathName); arrbytHashValue = oMD5Hasher.ComputeHash(oFileStream); oFileStream.Close(); strHashData = System.BitConverter.ToString(arrbytHashValue); strHashData = strHashData.Replace("-", ""); strResult = strHashData; } catch(System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "Error!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error, System.Windows.Forms.MessageBoxDefaultButton.Button1); } return(strResult); }
Initial URL
http://www.codeproject.com/KB/files/dt_file_hasher.aspx
Initial Description
Initial Title
Get MD5 Hash of any file
Initial Tags
Initial Language
C#