title: Check MD5 Before Saving file to machine
body: <p>I want to check MD5 hash without saving it,</p>
  
  <p>to check if it exists already 
  i have tried this code below but it just wont compute the MD5 of the file if its not saved already. </p>
  
  <p>so i was thinking about filling the file in a <strong>byte array</strong> then get that byte array MD5  but that will leave me with no bytes in the file. </p>
  
  <p>Any suggestions ? this is my code </p>
  
  <pre><code>public void ProcessRequest(HttpContext context)
  {
      if (context.Request.Files.Count &gt; 0)
      {
          HttpFileCollection files = context.Request.Files;
          for (int i = 0; i &lt; files.Count; i++)
          {
              HttpPostedFile file = files[i];
              string ServerPath = context.Server.MapPath("~/uploads/" + file.FileName);
              string Name = file.FileName;
              string MD5 = GetMD5(ServerPath);
              int Size = file.ContentLength;
              string type = file.ContentType;
              file.SaveAs(ServerPath);   
          }
      }
  }
  </code></pre>
  
  <p>This is  <code>getMD5</code> Method</p>
  
  <pre><code>public string GetMD5(string fileName)
  {
      try
      {
          using (var md5 = MD5.Create())
          {
              using (var stream = File.OpenRead(fileName))
              {
                  string Hash = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "");
                       return Hash;
              }
          }
      }
      catch (Exception ex)
      {
          throw ex;
      }
  }
  </code></pre>