byte[] b = (byte[])(read.Rows[0]["txt_filecontent"]);//获取二进制文件
ByteConvertWord(b, read.Rows[0]["txt_filename"].ToString(), read.Rows[0]["txt_file_type"].ToString(), path);//将二进制文件转化成具体类型的文件
/// <summary>
/// 二进制数据转换为word文件
/// </summary>
/// <param name="data">二进制数据</param>
/// <param name="fileName">word文件名</param>
/// <returns>word保存的相对路径</returns>
public void ByteConvertWord(byte[] data, string fileName, string filetype, string savepath)
{
string filePath = savepath + "\" + fileName + filetype;
FileStream fs;
if (System.IO.File.Exists(filePath))
{
fs = new FileStream(filePath, FileMode.Truncate);
}
else
{
fs = new FileStream(filePath, FileMode.CreateNew);
}
BinaryWriter br = new BinaryWriter(fs);
br.Write(data, 0, data.Length);
br.Close();
fs.Close();
}