欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#自適應(yīng)合并文件的方法

 更新時(shí)間:2015年07月07日 14:39:06   作者:DTC2  
這篇文章主要介紹了C#自適應(yīng)合并文件的方法,涉及C#基于FileStream類實(shí)現(xiàn)文件讀寫操作的相關(guān)技巧,非常簡單實(shí)用,需要的朋友可以參考下

本文實(shí)例講述了C#自適應(yīng)合并文件的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

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#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論