C#自適應(yīng)合并文件的方法
更新時間: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)文章
關(guān)于C#連接SQL Server時提示用戶登錄失敗的解決方法
在用C#開發(fā)windows端程序并連接SQL Server時有可能會遇到數(shù)據(jù)庫登錄失敗的問題,下面小編給大家?guī)砹薈#連接SQL Server時提示用戶登錄失敗的解決方法,感興趣的朋友一起看看吧2021-11-11
基于WPF實(shí)現(xiàn)3D導(dǎo)航欄控件
這篇文章主要介紹了如何基于WPF實(shí)現(xiàn)簡單的3D導(dǎo)航欄控件效果,文中的示例代碼講解詳細(xì),對我們的學(xué)習(xí)或工作有一定幫助,需要的小伙伴可以參考一下2024-03-03
C#中遍歷DataSet數(shù)據(jù)集對象實(shí)例
這篇文章主要介紹了C#中遍歷DataSet數(shù)據(jù)集對象實(shí)例,經(jīng)常忘記如何操作DataSet,這里記下來并分享,讓需要的朋友可以參考下2014-08-08
.NET實(shí)現(xiàn)定時發(fā)送郵件代碼(兩種方式)
經(jīng)常發(fā)郵件的朋友都知道,郵箱有個特殊功能,可以設(shè)定郵件發(fā)送時間,定時發(fā)送,這個功能是怎么實(shí)現(xiàn)的呢?接下來,小編給大家分享.NET實(shí)現(xiàn)定時發(fā)送郵件的代碼,有需要的朋友可以參考下2015-08-08

