图片转换成bas位字符串e

 1 public static string ImgToBase64String(string filepath)
 2         {
 3             try
 4             {
 5                 Bitmap bmp = new Bitmap(filepath);
 6                 MemoryStream ms = new MemoryStream();
 7                 bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
 8                 byte[] arr = new byte[ms.Length];
 9                 ms.Position = 0;
10                 ms.Read(arr, 0, (int)ms.Length);
11                 ms.Close();
12                 string pic = Convert.ToBase64String(arr);
13                 return pic;
14 
15             }
16             catch
17             {
18                 return false.ToString();
19             }
20         }

 

posted @ 2015-05-22 10:24  执著者  阅读(246)  评论(0编辑  收藏  举报