C# 使用SoftArtisan';让WordWriter合并文档
这是我的文件模型:C# 使用SoftArtisan';让WordWriter合并文档,c#,content-type,C#,Content Type,这是我的文件模型: public class File { public int Id { get; set; } public string fileName { get; set; } public byte[] fileContent { get; set; } public string contentType { get; set; } public long fileSize { get
public class File
{
public int Id { get; set; }
public string fileName { get; set; }
public byte[] fileContent { get; set; }
public string contentType { get; set; }
public long fileSize { get; set; }
}
内容类型为:application/msword
List<File> liste = new List<File>();
我得到以下例外情况:
此文档不是兼容的Word文档。WordWriter支持
使用Word 97、Word 2000、Word XP和Word 2003创建的文档。
System.IO.IOException:无法读取整个标头-读取1字节;
应为512字节
你知道如何设置流的内容类型吗?
我无法将文件写入磁盘并对其进行设置。尝试使用.doc扩展名而不是.docx保存文档,然后tryDocument将保持流状态,因此不设置扩展名。从模型的字节[]读取流。
foreach (var doc in liste)
{
using (MemoryStream ms = new MemoryStream())
{
ms.Read(doc.fileContent, 0, Convert.ToInt32(doc.fileSize));
Document documentToAppend = WA.Open(ms);
baseDocument.Append(documentToAppend);
}
}