usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Linq;usingSystem.Text;namespaceconsoleapplication2{Internal classProgram { Public Static voidMain (string[] args) { using(varFS =NewFileStream ("Test.txt", FileMode.Open, FileAccess.Read)) { using(varDest =NewFileStream ("Dest.txt", FileMode.OpenOrCreate, FileAccess.Write)) { varbytes =New byte[1024x768]; while(true) { varRead = fs. Read (Bytes,0, Bytes. Length); if(Read = =0) { Break; } Else{dest. Write (Bytes,0, read); } } } } } #regionTool methods/// <summary> ///Find out all the indexes of substrings in the string, "CCC" in "CCCCC" that there is only one/// </summary> /// <param name= "str" ></param> /// <param name= "SubStr" ></param> /// <returns></returns> Private Staticlist<int> Allindexof (stringStrstringsubStr) {List<int> li =Newlist<int>(); vari =0; I=Str. IndexOf (SUBSTR, stringcomparison.ordinal); while(I! =-1) {li. ADD (i); I= str. IndexOf (SUBSTR, i +substr.length, stringcomparison.ordinal); } returnLi; } /// <summary> ///Select Sort/// </summary> /// <param name= "arr" ></param> Private Static voidSort (int[] arr) { for(inti =0; I < arr. Length-1; i++) { for(intj = i +1; J < arr. Length; J + +) { if(Arr[i] >Arr[j]) {Swap (refArr[i],refArr[j]); } } } } /// <summary> ///Bubble Sort/// </summary> /// <param name= "arr" ></param> Private Static voidBubblesort (int[] arr) { for(inti =0; I < arr. Length-1; i++) { for(intj =0; J < arr. Length-1I J + +) { if(Arr[j] > arr[j +1]) {Swap (refARR[J],refArr[j +1]); } } } } /// <summary> ///Exchange two values/// </summary> /// <param name= "a" ></param> /// <param name= "B" ></param> /// <typeparam name= "T" ></typeparam> Private Static voidSwap<t> (refT A,refT B) {T T=A; A=b; b=T; } Private Static voidPrint<t>(t[] arr) {stringstr =typeof(T) +"["; if(arr.) Length! =0) { for(vari =0; I < arr. Length-1; i++) {str+ = Arr[i] +", "; } STR+ = Arr[arr. Length-1]; } STR+="]"; Print (str); } Private Static voidJprint<t>(t[] arr) {stringstr =typeof(T) +"["; if(arr.) Length! =0) { for(vari =0; I < arr. Length-1; i++) {str+ = Arr[i] +", "; } STR+ = Arr[arr. Length-1]; } STR+="]"; Print (str); } Public Static voidPrint (stringObjparams Object[] Arg) {Console.WriteLine (obj, Arg); } Public Static voidJprint (stringObjparams Object[] Arg) {Console.WriteLine (obj, Arg); } Public Static voidPrint (Objectobj) {Console.WriteLine (obj); } Public Static voidJprint (Objectobj) {Console.WriteLine (obj); } /// <summary> ///get a value of type int/// </summary> /// <returns></returns> Public Static intGetInt () {inti; while(true) { Try{i=Convert.ToInt32 (Console.ReadLine ()); Break; } Catch(FormatException e) {Console.WriteLine (e.message); } } returni; } Public Static intGetInt2 (stringstr) { while(true) { Try { vari =Convert.ToInt32 (str); returni; } Catch(FormatException e) {Console.WriteLine (e.message); STR=Console.ReadLine (); } } } Public Static stringGetString () {returnConsole.ReadLine (); } Public Static Doublegetdouble () {Doublei; while(true) { Try{i=convert.todouble (Console.ReadLine ()); Break; }//Catch Catch(FormatException e) {Console.WriteLine (e.message); } } returni; } #endregion }}
C # Copy files