C#自順應歸並文件的辦法。本站提示廣大學習愛好者:(C#自順應歸並文件的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#自順應歸並文件的辦法正文
本文實例講述了C#自順應歸並文件的辦法。分享給年夜家供年夜家參考。詳細完成辦法以下:
using System;
using System.IO;
namespace MergeFile
{
class Program
{
public static void Main(string[] args)
{
int count=1;
string sourcepath=@"D:\SplitFile";
string filetomerge=@"C:\編程的奧妙.pdf";
FileStream ftm = new FileStream(filetomerge, FileMode.Create, FileAccess.Write);
BinaryWriter bw=new BinaryWriter(ftm);
string filepath;
while(File.Exists(filepath=sourcepath+Path.DirectorySeparatorChar+Path.GetFileName(filetomerge)+count++))
{
FileStream fsr = new FileStream(filepath, FileMode.Open, FileAccess.Read);
BinaryReader br=new BinaryReader(fsr);
bw.Write(br.ReadBytes((int)fsr.Length));
br.Close();
fsr.Close();
}
bw.Flush();
bw.Close();
ftm.Close();
}
}
}
願望本文所述對年夜家的C#法式設計有所贊助。