Csharp/C#教程: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#程序设计有所帮助。

您可能感兴趣的文章:C#文件合并的方法C#合并多种格式文件为PDF的方法

标签: 自适应 方法

C++中约数定理的实例详解

include包含头文件的语句中,双引号和尖括号的区别(详解)

上述就是C#学习教程:C#自适应合并文件的方法分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/906665.html

(0)
上一篇 2021年10月24日
下一篇 2021年10月24日

精彩推荐