Using the method of intercepting the string, the order of the original document is scrambled and re-assembled. When a string is intercepted, only the "," interval is considered, no other punctuation is considered, and the readability of the reorganization is not considered. To be improved later!
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;usingSystem.Collections;namespacewindowsformsapplication3{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } Public stringtxt//Specify the text content under the path Public stringSubtxt;//Captured text content Public intIndex//intercepted Index Public intfrist=0;//determine whether to intercept from text Public intA//change the index position of "," Private voidButton1_Click (Objectsender, EventArgs e) { //Openfiledialog1.showdialog ();Openfiledialog1.filter ="text Files |*.txt"; DialogResult isOK= Openfiledialog1.showdialog ();//enumerate the actions of a user on a dialog box if(isok==DialogResult.OK) {strings = openfiledialog1.filename;//the selected file path if(ListBox1.Items.Contains (s)) {MessageBox.Show ("Repeat the options! "); } Else{LISTBOX1.ITEMS.ADD (s);//Add Path } } } Public voidSubs () {ArrayList Al=NewArrayList (); for(inti =0; i < ListBox1.Items.Count; i++)//number of selected text { strings =Listbox1.items[i]. ToString (); StreamReader SR=NewStreamReader (S, Encoding.default);//reading text contentTXT =Sr. ReadToEnd (); Txt. Trim ();//Remove the leading and trailing spacesindex = txt. IndexOf (","); if(Index! =-1)//In order to determine if there is "," in the text { while(true) { if(Frist = =0) {Subtxt= txt. Substring (0, index);//Intercept charactersA = index +1;//index plus 1, skip this punctuation, check from the next startFrist + =1; Al. ADD (Subtxt); } Else{Index= txt. IndexOf (",", a); Subtxt= txt. Substring (A, index-a); A= index +1; Al. ADD (Subtxt); if(A > txt.) LastIndexOf (",") ) {a=0; Break; }}}} Sr. Close (); } Frist=0; stringFileName =@"d:\ generating text. txt";//Create a new TXT file to store scrambled text if(! File.exists (FileName))//determine if this text has been created{file.create (FileName). Close (); } Else{file.createtext (FileName). Close ();//Create a text file} Random R=NewRandom ();//take random numbers to randomly combine strings for(inti =0; I < al. Count; i++) { intSuijishu = R.next (0, AL. Count); StreamReader SRE=NewStreamReader (FileName, Encoding.default); if(SRE. ReadToEnd () = ="") {sre. Close (); StreamWriter SW=NewStreamWriter (FileName,false);//writes a stream, writes a stringSW. Write (Al[suijishu]); Sw. Close (); } Else { stringJieshou =SRE. ReadToEnd (); Sre. Close (); StreamWriter SW=NewStreamWriter (FileName,true); Sw. Write (Jieshou+Al[suijishu]); Sw. Flush (); Sw. Close (); } SRE. Close (); } } Private voidButton2_Click (Objectsender, EventArgs e) {Subs (); } Private voidButton3_Click (Objectsender, EventArgs e) {DialogResult isOK=Openfiledialog1.showdialog (); if(isOK = =DialogResult.OK) {strings =Openfiledialog1.filename; System.Diagnostics.Process.Start (s);//open a file under the specified path } } }}
Automatic generation of articles