[代码] 文件合并
http://www.oschina.net/code/snippet_222150_8304
03 | string filetomerge= @"C:\temp\data.bin" ; |
04 | string targetpath= @"D:\store" ; |
05 | string strFileName = filetomerge.Substring(filetomerge.LastIndexOf(Path.DirectorySeparatorChar) + 1); |
06 | FileStream fsr1 = new FileStream(targetpath+ Path.DirectorySeparatorChar + strFileName + "1" , FileMode.Open, FileAccess.Read); |
07 | FileStream fsr2 = new FileStream(targetpath+ Path.DirectorySeparatorChar + strFileName + "2" , FileMode.Open, FileAccess.Read); |
08 | byte [] btArr = new byte [fsr1.Length+fsr2.Length]; |
09 | fsr1.Read(btArr, 0, Convert.ToInt32(fsr1.Length)); |
10 | fsr2.Read(btArr, Convert.ToInt32(fsr1.Length), Convert.ToInt32(fsr2.Length)); |
13 | FileStream fsw = new FileStream(%%2 + Path.DirectorySeparatorChar+ strFileName, FileMode.Create, FileAccess.Write); |
14 | fsw.Write(btArr, 0, btArr.Length); |