C # Copy files

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.