把指定图片转换为byte

#region 把指定图片转换为byte
       
/// <summary>
       
/// 把指定图片转换为byte
       
/// </summary>
       
/// <param name="path">图形路径</param>
       
/// <returns></returns>
        public static byte[] GetPhoto(string path)
        {
           
string str = path;
           
byte[] photo = new byte[0];
           
if (File.Exists(path))
            {
                FileStream file
= new FileStream(str, FileMode.Open, FileAccess.Read);
                photo
= new byte[file.Length];
                file.Read(photo,
0, photo.Length); file.Close(); } return photo;
        }
       
#endregion

原文地址:https://www.cnblogs.com/jhabb/p/1925491.html