title: Unable to convert Images stored in resource file to Base64 string in Asp.net [C#]
body: <p>I am trying to get images stored in resource file and then trying to convert it to base64 string. however it generate garbage string below is my code:</p>
  
  <pre><code>String imgBase64=Base64FromByteArray(ExtractResource(Properties.Resources.products_tipp_110));
  
  public static byte[] ExtractResource(Bitmap image)
      {
          MemoryStream ms = new MemoryStream();
  
          image.Save(ms, ImageFormat.Png);
          if (ms == null)
              return null;
          byte[] imageByteArray = new byte[ms.Length];
          ms.Read(imageByteArray, 0, imageByteArray.Length);
          return imageByteArray;
      }
  
  private static string Base64FromByteArray(byte[] image)
      {
          return "base64:" + Convert.ToBase64String(image);
      }
  
  
  output: 
     base64:AAAAAAAAAAAAAAAAAAAAAAAAAAAAA..... with all A's
  </code></pre>