把指定图片转换为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

posted @ 2011-01-04 15:11  落冰  阅读(508)  评论(0编辑  收藏  举报