Well, two things.
You can compute the MD5 of any file by e.g.
using System.IO;
using System.Security.Cryptography;
namespace Bernie
{
public class FileUtil
{
private static object _Lock = new object();
public static byte[] GetMD5Hash(string Filename)
{
lock (_Lock)
{
if (File.Exists(Filename))
{
using (MD5 md5 = MD5.Create())
{
using (FileStream stream = File.OpenRead(Filename))
{
return md5.ComputeHash(stream);
}
}
}
else
{
return null;
}
}
}
}
}
But you need to store the "correct" values somewhere, and then compare them with the computed values. And that's the point where the security issues (and security issues are the reason why you want to do so, isn't it?) may come in again: they have to be located in an extra file, and you cannot add the MD5 of that file into that list in the file, as its MD5 would change.
But of course, a virus infection could be detected.
By the way, I'd do the check in static Main() already.