C# 把byte[]输出为图片文件

        /// <summary>
        /// 将byte[]输出为图片
        /// </summary>
        /// <param name="path">输出图片的路径及名称</param>
        /// <param name="picByte">byte[]数组存放的图片数据</param>
        public void Write(string path,byte[] picByte)
        {
            FileStream fs = new FileStream(path, FileMode.Create);
            BinaryWriter bw = new BinaryWriter(fs);
            //开始写入
            bw.Write(picByte, 0, picByte.Length);
            //关闭流
            bw.Close();
            fs.Close();
        }

调用:

string path = @"F:\testpic.jpg";

Write(path,picByte);

猜你喜欢

转载自blog.csdn.net/hk_jy/article/details/80320381
今日推荐