文件合并
来源:互联网 发布:k歌软件 mtv 编辑:程序博客网 时间:2024/04/28 22:16
<script type="text/javascript"><!--google_ad_client = "pub-9528830580198364";/* 文章顶部广告(方框)300*250 */google_ad_slot = "0068799835";google_ad_width = 300;google_ad_height = 250;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
作业:文件合并工具:c#代码
作业:文件合并工具:c#代码
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
namespace splitfile
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox lissource;
private System.Windows.Forms.Button btnscan;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button btndes;
private System.Windows.Forms.TextBox txtdes;
private System.Windows.Forms.OpenFileDialog opensource;
private System.Windows.Forms.OpenFileDialog opendes;
private System.Windows.Forms.Button btnmerge;
private System.Windows.Forms.ProgressBar prgdis;
private System.Windows.Forms.Label lbldis;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
Windows 窗体设计器生成的代码
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
void adddes()
{
opendes.ShowDialog();
txtdes.Text=opendes.FileName;
}
void additem()
{
string[] path;
opensource.ShowDialog();
path=opensource.FileNames;
for(int i=0;i<path.Length;i++)
{
lissource.Items.Add(path[i]);
}
}
void merge()
{
if(lissource.Items.Count==0)
{
MessageBox.Show(this,"源文件没有指定!","失败");
return;
}
if(txtdes.Text.Equals(""))
{
MessageBox.Show(this,"目标文件没有指定!","失败");
return;
}
string content;
prgdis.Maximum=lissource.Items.Count;
for(int i=0;i<lissource.Items.Count;i++)
{
string sourpath=@lissource.Items[i].ToString();
StreamReader sr=new StreamReader(sourpath,Encoding.Default,true,512);
content=sr.ReadToEnd();
sr.Close();
string despath=@txtdes.Text;
StreamWriter sw=new StreamWriter(despath,true,Encoding.Default,512);
sw.Flush();
sw.Write(content);
sw.Close();
prgdis.Increment(1);
if(prgdis.Value==prgdis.Maximum)
{
MessageBox.Show(this,"合并成功!","成功");
lissource.Items.Clear();
txtdes.Text="";
prgdis.Value=0;
return;
}
}
}
private void btnscan_Click(object sender, System.EventArgs e)
{
additem();
}
private void btndes_Click(object sender, System.EventArgs e)
{
adddes();
}
private void btnmerge_Click(object sender, System.EventArgs e)
{
merge();
}
}
}
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
namespace splitfile
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox lissource;
private System.Windows.Forms.Button btnscan;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button btndes;
private System.Windows.Forms.TextBox txtdes;
private System.Windows.Forms.OpenFileDialog opensource;
private System.Windows.Forms.OpenFileDialog opendes;
private System.Windows.Forms.Button btnmerge;
private System.Windows.Forms.ProgressBar prgdis;
private System.Windows.Forms.Label lbldis;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
Windows 窗体设计器生成的代码
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
void adddes()
{
opendes.ShowDialog();
txtdes.Text=opendes.FileName;
}
void additem()
{
string[] path;
opensource.ShowDialog();
path=opensource.FileNames;
for(int i=0;i<path.Length;i++)
{
lissource.Items.Add(path[i]);
}
}
void merge()
{
if(lissource.Items.Count==0)
{
MessageBox.Show(this,"源文件没有指定!","失败");
return;
}
if(txtdes.Text.Equals(""))
{
MessageBox.Show(this,"目标文件没有指定!","失败");
return;
}
string content;
prgdis.Maximum=lissource.Items.Count;
for(int i=0;i<lissource.Items.Count;i++)
{
string sourpath=@lissource.Items[i].ToString();
StreamReader sr=new StreamReader(sourpath,Encoding.Default,true,512);
content=sr.ReadToEnd();
sr.Close();
string despath=@txtdes.Text;
StreamWriter sw=new StreamWriter(despath,true,Encoding.Default,512);
sw.Flush();
sw.Write(content);
sw.Close();
prgdis.Increment(1);
if(prgdis.Value==prgdis.Maximum)
{
MessageBox.Show(this,"合并成功!","成功");
lissource.Items.Clear();
txtdes.Text="";
prgdis.Value=0;
return;
}
}
}
private void btnscan_Click(object sender, System.EventArgs e)
{
additem();
}
private void btndes_Click(object sender, System.EventArgs e)
{
adddes();
}
private void btnmerge_Click(object sender, System.EventArgs e)
{
merge();
}
}
}
- 文件合并
- 合并文件
- 文件合并
- 文件合并
- 文件合并
- 文件合并
- 文件合并
- 合并文件
- 文件合并
- 文件切割/合并工具
- 文件分割,合并
- 文件合并排序
- PDF文件合并(MergePDF)
- 文件合并器
- JDOM合并XML文件
- 读写合并文件
- VBA EXCEL 文件合并
- excel 合并文件 vba
- 动态创建控件支持事件响应并可保存与读取
- 陌生的妻子
- 今天在这里创建博客了
- 夹克和西式套装
- 使用VS.Net IDE调试JavaScript
- 文件合并
- 数据建库之我见
- 13级台阶
- pb中常常碰到的问题
- shell初探
- 让VB菜鸟最快写出自己的外挂.通杀所有游戏
- 网页右下角向上浮出一个消息框
- Liferay研究之八:Liferay的层次划分---持久化及服务
- PL/SQL简介——异常定义、使用、捕获