【发布时间】:2017-01-25 06:34:03
【问题描述】:
我正在尝试编写文件活页夹。
我将两个文件中的字节数组合并到输出文件中。
看来我是在合并这两个文件而不是绑定它们,因为我希望在运行输出文件时能够同时运行这两个文件。
有没有一种方法可以组合这两个数组,但在运行时拆分它们以便能够运行这两个文件?
或者还有其他方法可以编写文件活页夹吗?
代码:
private void button3_Click(object sender, EventArgs e)
{
if(textBox1.Text != null & textBox2.Text !=null)
{
string filepath1 = this.textBox1.Text;
byte[] Bytes1 = File.ReadAllBytes(filepath1);
string filepath2 = this.textBox2.Text;
byte[] Bytes2 = File.ReadAllBytes(filepath2);
byte[] combinedbytes = new byte[Bytes1.Length + Bytes2.Length];
Array.Copy(Bytes1, 0, combinedbytes, 0, Bytes1.Length);
Array.Copy(Bytes2, 0, combinedbytes, Bytes1.Length, Bytes2.Length);
File.WriteAllBytes(outfile, combinedbytes);
}
【问题讨论】: