CheckSum of file in Memory before saving
Posted on 2011-02-21
I have a file that I want to verify that it is saved and not corrupted when written.
How can I get the check sum MD5 of the file in memory?
I know I can open the file and check it once it's saved. With the following.
protected string GetMD5HashFromFile(string fileName)
FileStream file = new FileStream(fileName, FileMode.Open);
MD5 md5 = new MD5CryptoServiceProvider();
byte retVal = md5.ComputeHash(file);
ASCIIEncoding enc = new ASCIIEncoding();