标签:
string Imagefilename 硬盘路径
protected string ImgToBase64String(string Imagefilename)
{
try
{
Bitmap bmp = new Bitmap(Imagefilename);
MemoryStream ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
byte[] arr = new byte[ms.Length];
ms.Position = 0;
ms.Read(arr, 0, (int)ms.Length);
ms.Close();
return Convert.ToBase64String(arr);
}
catch (Exception ex)
{
return null;
}
}
标签:
原文地址:http://www.cnblogs.com/ainidewen/p/4556545.html