title: In C#,two different methods to convert a gif file to byte[]
body: <p>I want to convert a gif file to byte[].</p>
  
  <p>I tried two method, but the result is different.Which one is right?</p>
  
  <p>Method 1:</p>
  
  <blockquote>
    <p>Using the <code>bytes =File.ReadAllBytes(filepath)</code>; This return a byte array.</p>
  </blockquote>
  
  <p>Methond 2:</p>
  
  <blockquote>
  <pre><code> private byte[] ImageToBytes(Image image, ImageFormat format)
          {
              using (MemoryStream ms = new MemoryStream())
              {
                  image.Save(ms, format);
                  return ms.ToArray();
              }
          }
  
  Bitmap image = new Bitmap(@"c:\\1.gif"); 
  </code></pre>
    
    <p>Then call<br>
    <code>bytes = ImageToBytes(image, ImageFormat.Gif);</code></p>
  </blockquote>
  
  <p>The two bytes have a little bit of difference. Which one I should trust?</p>