PanPen120 on CSDN original, such as other sites reproduced please pay attention to the layout and the source:
Http://write.blog.csdn.net/postedit
How to understand, flow is a form of data loading, our pictures, music, videos, files, folders ... These are files, are data, and we use the cool dog, cool, QQ music and other players directly open a MP3 file to hear the sound, this is just mp3 this file a form of display, files we can use to display, store, read, transmit, through the form of streams. According to the principle of computer only know 0 and 1 ... No deep
The file is read as a stream in the form of a byte array:
Public byte[] LoadFile (string filePath) { try { FileStream stream = new FileStream (FilePath, FileMode.Open); BinaryReader binary = new BinaryReader (stream); Binary. Basestream.seek (0, seekorigin.begin); Set the file pointer to file open byte[] filebinary = binary. Readbytes ((int) binary. Basestream.length); Stream. Close (); return filebinary; } catch (Exception ex) { throw ex; } }
To take the saved stream out:
public void SaveFile (String savepath, byte[] filebinary) { try { FileStream FileStream = new FileStream (Savepath, FileMode.OpenOrCreate); FileStream. Write (filebinary, 0, filebinary.length); FileStream. Close (); } catch (Exception ex) { throw ex;}} }
I will be a desktop picture in the form of a stream saved in the database look: PanPen120 in csdn original, such as other sites reproduced please note the layout and the source:
Http://write.blog.csdn.net/postedit
The initial solution of C # stream