C # File Operations Delete, copy, transfer multiple files [go]

Source: Internet
Author: User

string[] format = {"*.jpg","*.doc","*.exe","*.pdf","*.xls" }; # File stream Operations Delete, copy, transfer multiple files/// <summary>         ///Delete all pictures under folder/// </summary>         /// <param name= "Oldpngpath" >file path to delete</param>         /// <param name= "Newpngpath" >new directory to delete</param>         /// <param name= "GeSHi" >the format of the action file for example: *.png, *.xml</param>          Public voidDeleteAll (stringDelpath,stringformat) {             string[] files = Directory.GetFiles (Delpath, format[0]); foreach(stringFileinchfiles)             {File.delete (File); }         }         /// <summary>         ///Copy all pictures under folder/// </summary>         /// <param name= "Oldpngpath" >file path to be copied</param>         /// <param name= "Newpngpath" >new directory to which to copy</param>         /// <param name= "GeSHi" >the format of the action file for example: *.png, *.xml</param>          Public voidCopyall (stringOldpngpath,stringNewpngpath,stringformat) {             string[] files = Directory.GetFiles (Oldpngpath, format[0]); foreach(stringFileinchfiles) {                 stringOtherfile =Path.Combine (Oldpngpath, Path.getfilename (file)); File.Copy (file, Newpngpath+"\\"+path.getfilename (file)); }         }        /// <summary>         ///move all files under a folder/// </summary>         /// <param name= "Olderpath" >file directory to be moved</param>         /// <param name= "Topath" >New Catalog</param>          Public voidMoveall (stringOlderpath,stringTopath) {             string[] files = Directory.GetFiles (Delpath, format[0]); foreach(stringFileinchfiles) {File.move (File, topath);//Moving Files           }         }  

C # File Operations Delete, copy, transfer multiple files [go]

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.