把word文档保存到临时文件,然后把二进制数据写入数据库。建议同时写入文件的作者、大小、名字和摘要和修改时间以便于搜索。
读出来的时候把数据导出到临时文件再用Word打开就可以了

解决方案 »

  1.   

            /// <summary>
            /// 将Byte()转换为文件
            /// </summary>
            /// <param name="name">文件名</param>
            /// <param name="obj">文件路径</param>
            /// <param name="fileByte">Byte()数组</param>
            public void ChangeBtyeToFile(string filePath, byte[] fileByte)
            {
                FileStream fs;
                try
                {
                    fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);
                    fs.Write(fileByte, 0, fileByte.Length);
                    fs.Close();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }        /// <summary>
            /// 将文件序列化为Byte数组
            /// </summary>
            /// <param name="path">文件路径</param>
            /// <returns>Byte()</returns>
            public byte[] ChangeFileToByte(string filePath)
            {
                FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                byte[] tempByte = null;
                if (fs.Length > 0)
                {
                    tempByte = new byte[fs.Length];
                    fs.Read(tempByte, 0, Convert.ToInt32(fs.Length));
                }
                fs.Close();
                return tempByte;
            }
    希望对你有帮助