Home  >  Article  >  Database  >  将图片文件以byte的形式从导数据库中

将图片文件以byte的形式从导数据库中

WBOY
WBOYOriginal
2016-06-07 15:00:081532browse

byte[] FileByteArray = new byte[FileLength]; //图象文件临时储存Byte数组 //Stream StreamObject = UpFile.InputStream; //建立数据流对像 /////读取图象文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度 //StreamObject.Rea

 byte[] FileByteArray = new byte[FileLength];  //图象文件临时储存Byte数组
                //Stream StreamObject = UpFile.InputStream;             //建立数据流对像  

                /////读取图象文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度  
                //StreamObject.Read(FileByteArray, 0, FileLength);
                //StreamObject = null;
                FileStream fs = new FileStream(FullFilePath, FileMode.OpenOrCreate);
                BinaryReader rs = new BinaryReader(fs);
                FileByteArray = rs.ReadBytes(Convert.ToInt32(fs.Length));
                rs.Close();
                rs = null;
                fs.Close();
                fs = null;

                theNewFile.CONTENT = FileByteArray;

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn