C#自适应合并文件的方法
本文实例讲述了C#自适应合并文件的方法。分享给大家供大家参考。具体实现方法如下:
usingSystem;
usingSystem.IO;
namespaceMergeFile
{
classProgram
{
publicstaticvoidMain(string[]args)
{
intcount=1;
stringsourcepath=@"D:\SplitFile";
stringfiletomerge=@"C:\编程的奥秘.pdf";
FileStreamftm=newFileStream(filetomerge,FileMode.Create,FileAccess.Write);
BinaryWriterbw=newBinaryWriter(ftm);
stringfilepath;
while(File.Exists(filepath=sourcepath+Path.DirectorySeparatorChar+Path.GetFileName(filetomerge)+count++))
{
FileStreamfsr=newFileStream(filepath,FileMode.Open,FileAccess.Read);
BinaryReaderbr=newBinaryReader(fsr);
bw.Write(br.ReadBytes((int)fsr.Length));
br.Close();
fsr.Close();
}
bw.Flush();
bw.Close();
ftm.Close();
}
}
}
希望本文所述对大家的C#程序设计有所帮助。
热门推荐
8 天仓节祝福语简短
10 朋友升迁的祝福语简短
11 母亲祝福语简短微信
12 英文节日祝福语简短唯美
13 中秋送礼的祝福语简短
14 虎年幽默搞笑简短祝福语
15 新婚简短的祝福语大全
16 开业贺卡祝福语简短高级
17 除夕祝福语简短创意牛年
18 鸡年祝福语简短8字