【发布时间】:2023-03-05 15:33:01
【问题描述】:
我正在尝试使用字节数组将多个文件附加到单个文件中,但是当我尝试附加文件时,它只转换最后一个文件。我使用下面的代码:
byte[] outputBytes = new byte[0];
byte[] temp1 = System.IO.File.ReadAllBytes(@"D:\2.doc");
byte[] temp2 = System.IO.File.ReadAllBytes(@"D:\3.doc");
outputBytes = new byte[temp1.Length + temp2.Length];
Buffer.BlockCopy(temp1,0,outputBytes,0,temp1.Length * sizeof(byte));
Buffer.BlockCopy(temp2,0,outputBytes,0,temp2.Length * sizeof(byte));
System.IO.File.WriteAllBytes(@"D:\myOutPut.doc",outputBytes);
我正在创建一个显示所有文件内容的输出文件。
谢谢。
【问题讨论】:
-
或 Efficient way to combine multiple text files 或其他几个答案。你应该先用谷歌搜索一下。
-
嘿@liam,我试试你的链接,但没有成功。它只转换一个word文件。