#region save files to local///<summary>///save files to local///</summary>///<param name= "pscontent" > File binary Data String </param>///<param name= "psfilename" > file name, must be with suffix </param> private void savefile (String pscontent,
String psfilename) {byte[] accessory = convert.frombase64string (pscontent); System.AppDomain.CurrentDomain.BaseDirectory the base directory string Vsaccessorypath of the FETCH program =
System.AppDomain.CurrentDomain.BaseDirectory.TrimEnd (' \ \ ') + ' \ \ ' + psfilename;
FileStream FileStream = null;
try {//file.create method (String): Creates or overwrites a File in the specified path.
FileStream = File.create (Vsaccessorypath); catch (System.IO.IOException e) {}//filestream.write method:writes a block of B
Ytes to the file stream. FileStream.Write (accessory, 0, accessory.
Length);
Filestream.flush method: Clears all buffers for the stream so that all buffered data is written to the underlying device.
Filestream.flush (); FiLestream.close method:closes the "file and releases any of the associated with the" current file stream.
Filestream.close (); } #endregion
This paper url:http://www.bianceng.cn/programming/csharp/201410/45587.htm
If the file stream is saved in the database:
String vssql = ""; Get the contents of the saved file to be converted from the database (for example, convert the file to a byte stream before saving it to the database)
DataSet dscontent = database operation to obtain dataset;
Byte[] Vbcontent = (byte[]) (dscontent.tables[0). rows[0]["column name for saving file contents in database"]);
String vsContent = Convert.tobase64string (vbcontent);
The way a byte stream is saved in a database: