C # file stream operations-delete, copy, and transfer multiple files

Source: Internet
Author: User
String [] format = {"*. jpg ","*. doc ","*. EXE ","*. PDF ","*. xls "}; C # file stream operation-delete, copy, and transfer multiple files /// <summary> /// delete all the images in the folder /// </Summary> /// <Param name = "oldpngpath"> file path to be deleted </param> // <Param name = "newpngpath"> new directory to be deleted </param> /// <Param name = "geshi"> the format of the Operation file is as follows: *. PNG ,*. XML </param> Public void deleteall (string delpath, string format) {string [] files = directory. getfiles (delpath, format [0]); foreach (string file in files) {file. delete (File );}} /// <summary> /// copy all the images in the folder /// </Summary> /// <Param name = "oldpngpath"> path of the file to be copied </param> /// <Param name = "newpngpath"> the new directory to be copied </param> /// <Param name = "geshi"> the format of the Operation file is as follows: *. PNG ,*. XML </param> Public void copyall (string oldpngpath, string newpngpath, string format) {string [] files = directory. getfiles (oldpngpath, format [0]); foreach (string file in files) {string otherfile = path. combine (oldpngpath, path. getfilename (File); file. copy (file, newpngpath + "\" + path. getfilename (File ));}} /// <summary> /// move all files in the folder /// </Summary> /// <Param name = "olderpath"> file directory to be moved </ param> // <Param name = "topath"> new directory </param> Public void moveall (string olderpath, string topath) {string [] files = directory. getfiles (delpath, format [0]); foreach (string file in files) {file. move (file, topath); // move the file }}

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.