Check File Integrity

  • Thread starter Thread starter giftson.john
  • Start date Start date
G

giftson.john

Hi,

Anybody knows how to check the file integrity?

I need to check the file integrity whether it is corrupt or not. Can
anyone please advice?
 
Once the file is created and you know it is good, create an MD5 hash
of it. Then, in the future, you can create another MD5 hash and
compare the value to the original. If one BIT is different you will
get a different hash.

Here is a routine that will give you the MD5 hash of a file.

public string Compute_MD5Hash_FromFile(string FileNameAndPath)
{
using (FileStream fs = new FileStream(FileNameAndPath,
FileMode.Open))
{
return Convert.ToBase64String(new
MD5CryptoServiceProvider().ComputeHash(fs));
}
}


http://www.codershangout.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top