首页 > Windows开发 > 详细

c# byte转docx

时间:2018-10-11 20:31:04      阅读:151      评论:0      收藏:0      [点我收藏+]

问题情境:

  docx文件放进resource中,再用程序读出来的时候是二进制数组。

解决办法:

public string ByteConvertWord(byte[] data, string fileName)
        {
            string savePath = @"\\" + fileName + ".docx";
            string filePath = Application.StartupPath + savePath;
            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();
            return filePath;
        }

 问题实质:

  还是IO流读写问题,通过文件可以还原保存为多种格式,包括docx。

c# byte转docx

原文:https://www.cnblogs.com/gaara-zhang/p/9774521.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!