C# 读取图片转成Base64编码
1 /// <summary> 2 /// 根据图片的路径解析成图片资源 3 /// </summary> 4 /// <param name="filePath"></param> 5 /// <returns></returns> 6 public static string BitmapImageToByteArray(string filePath) 7 { 8 byte[]? byteArray = null; 9 if (File.Exists(filePath)) 10 byteArray = File.ReadAllBytes(filePath); 11 string pic = Convert.ToBase64String(byteArray); 12 return pic; 13 }