title: Same file different MD5 checksum in C#
body: <p>Here is the scenario. I have a winforms application which has an auto-update feature. This application contains a method which calculates the md5 checksum of the current (local) exe file and compares it with the md5 checksum of the (server) exe file to determine if there is any new updates on the server by comparing the hashes of the 2 files on local machine and the server. </p>
  
  <p>Now this method works perfectly on some PCs that I have and when I run the application it gives same checksum hashes. The problem is on some other PCs I always get the auto-update message because I'm getting different MD5 hashes, Now after that the application starts the auto-update and re-downloads the file on my server, I get a new exe file with a totally different hashes. I'm really confused what is possibly can cause this? is it a problem from the C# downloading method? is it a problem from the md5 function it self? any inputs would be appreciated...</p>
  
  <p>EDIT: a method to calculate md5 checksum</p>
  
  <pre><code>public static string GetMD5HashFromFile(string filename)
  {
      using (var md5 = new MD5CryptoServiceProvider())
      {
          var buffer = md5.ComputeHash(File.ReadAllBytes(filename));
          var sb = new StringBuilder();
          for (int i = 0; i &lt; buffer.Length; i++)
          {
              sb.Append(buffer[i].ToString("x2"));
          }
          return sb.ToString();
      }
  }
  </code></pre>