首页  >  文章  >  后端开发  >  C#文件合并代码

C#文件合并代码

大家讲道理
大家讲道理原创
2016-11-10 10:18:081889浏览

using System;
using System.IO;
string filetomerge=@"C:\temp\data.bin";
string targetpath=@"D:\store";
string strFileName = filetomerge.Substring(filetomerge.LastIndexOf(Path.DirectorySeparatorChar) + 1);
FileStream fsr1 = new FileStream(targetpath+ Path.DirectorySeparatorChar + strFileName + "1", FileMode.Open, FileAccess.Read);
FileStream fsr2 = new FileStream(targetpath+ Path.DirectorySeparatorChar + strFileName + "2", FileMode.Open, FileAccess.Read);
byte[] btArr = new byte[fsr1.Length+fsr2.Length];
fsr1.Read(btArr, 0, Convert.ToInt32(fsr1.Length));
fsr2.Read(btArr, Convert.ToInt32(fsr1.Length), Convert.ToInt32(fsr2.Length));
fsr1.Close();
fsr2.Close();
FileStream fsw = new FileStream(%%2 + Path.DirectorySeparatorChar+ strFileName, FileMode.Create, FileAccess.Write);
fsw.Write(btArr, 0, btArr.Length);
fsw.Flush();
fsw.Close();

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn