C # file splitter

xiaoxiao2021-03-06  96

When combined, two layers of copy commands can be combined, and some files can be combined. In fact, the general length of the test command line can theoretically realize the combination of unlimited split files, but the practical value is not high, and the demolition of 10,000 documents. Not only is this single-threaded method, not only the efficiency is low, but it should be divided and combined with a better algorithm. This program can eventually be classified as "toys". Using system.drawing; using system.componentmodel; using system.windows.form; using system.data; namespace filesplit {////

/// Form1 summary description. /// public class Form1: System.Windows.Forms.Form {private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.OpenFileDialog ofd; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; /// /// required Designer variable. /// private system.componentmodel.container Components = NULL; Public Form1 () {// // Windows Form Designer Support To Support // InitializationComponent (); // // Todo: Call in InitializationComponent Add any constructor code //} /// /// Clean all the resources being used. /// Protected Override Void Dispose (Bool Disposing) {if (disponents! = null) {Components.dispose ();}} Base.Dispose (DISPOSION);} #Region Windows Form The code generated by the designer /// /// designer supports the required method - do not use the code editor to modify the // / this method.

/// private void InitializeComponent () {this.textBox1 = new System.Windows.Forms.TextBox (); this.textBox2 = new System.Windows.Forms.TextBox (); this.button1 = new System. Windows.Forms.Button (); this.Button2 = new system.windows.Forms.Button (); this.ofd = new system.windows.forms.openfiledialog (); this.label1 = new system.windows.formel1 = new system.windows.forms.label (); This.Label2 = new system.windows.forms.label (); this.suspendlayout (); /// textBox1 // this.textbox1.borderStyle = system.windows.Forms.Borderstyle.FixedSingle; this.textbox1 .Location = new system.drawing.point (16, 16); this.textbox1.name = "textbox1"; this.textBox1.readonly = true; this.textbox1.size = new system.drawing.size (376, 21) "This.TextBox1.tabindex = 0; this.textBox1.text =" file path "; // // textbox2 // this.textBox2.Location = new system.drawing.point (56, 48); this.textbox2.name = "TextBox2"; this.textbox2.size = new system.drawing.size (72, 21); this.textbox2.tabind EX = 1; this.TextBox2.text = ""; // // button1 // this.button1.flatstyle = system.windows.Forms.Flatstyle.System; this.button1.location = new system.drawing.point (200 , 48); this.button1.name = "button1"; this.button1.size = new system.drawing.size (272, 24); this.button1.tabindex = 2; this.button1.text = "split" ; this.button1.Click = new System.EventHandler (this.button1_Click); // // button2 // this.button2.FlatStyle = System.Windows.Forms.FlatStyle.System; this.button2.Location = new System. Drawing.point (400, 16); this.Button2.name =

"Button2"; this.button2.size = new system.drawing.size (72, 24); this.button2.tabindex = 3; this.button2.text = "Browse"; this.button2.click = new system. EventHandler (this.button2_click); // // label1 // this.label1.location = new system.drawing.point (16, 48); this.label1.name = "label1"; this.label1.size = new system .Drawing.size (32, 23); this.label1.tabindex = 4; this.label1.text = "size"; /// label2 // this.label2.location = new system.drawing.point (136, 48); this.label2.name = "label2"; this.label2.size = new system.drawing.size (56, 16); this.label2.tabindex = 5; this.label2.text = "kb"; / / // form1 // this.autoscalebasesize = new system.drawing.size (6, 14); this.clientsize = new system.drawing.size (498, 79); this.controls.add (this.label2); this .Controls.add (this.Label1); this.controls.add (this.button2); this.Controls.add (this.button1); this.controls.add (this.TextBox2); this.controls.add (This.Add (this .TextBox1); this.Formbord erStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "Form1"; this.Text = "Spliter"; this.ResumeLayout (false);} #endregion ///

/// The primary entry point of the application.

/// [stathread] static void main () {Application.run (new form1 ());} private void button2_click (object sender, system.eventargs e) {if (this.ofd.showdialog ()! = System.Windows.Forms.DialogResult.OK) {return;} this.textBox1.Text = ofd.FileName;} private void button1_Click (object sender, System.EventArgs e) {try {int i = 1; try {i = INT.PARSE (THISTEXTBOX2.TEXT); if (i <= 0) {system.exception EE = new exception (); throw ee;} i * = 1000;} catch {i = 0; system.windows.forms .Messagebox.show ("Input Split Number is incorrect"); return;} #region "Assign folder" int count = 1; string Workpath = OFD.FILENAME.TOSTRING () "split"; while (true) { IF (! system.io.directory.exists (workpath)) {breaf;} else {if (! system.io.directory.exists (Workpath "_ " count.toString ()) {WorkPath =" _ " Count.tostring (); Break;} else {Count ;}}} System.IO.Directory.CreateDirectory (workpath); #endregion System.IO.FileStream f = new System.IO.FileStream (ofd.FileName, System.IO.FileMode.Open); System.IO. BinaryReader R = New System.io.binaryReader (f); long L = f.Length; long x = 0; int filecount = 1; for (; x

} X ;} f2.close (); FileCount ;} f.close (); system.io.StreamWriter T = new system.io.StreamWriter (system.io.ipen (Workpath "//" "combination file .bat ", system.io.filemode.create), System.Text.Encoding.default; T.WriteLine (" @ echo off "); T.Write (" copy "); int tempcount = 0; for (int For2 = 1; for2

转载请注明原文地址:https://www.9cbs.com/read-105338.html

New Post(0)