把指定图片转换为byte

作者:互联网   出处:控件中国网   2014-11-05 19:21:09   阅读:1

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


 

Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat