I/O Directory class

Source: Internet
Author: User

Directory Class

The directory class is located in the System.IO namespace. The directory class provides static methods for creating movement and enumeration operations in directories and subdirectories. In addition, you can access and manipulate a wide variety of directory properties.

1. Directory Creation method: Publicstatic DirectoryInfo createdirectory (string path);

    1. Directory. CreateDirectory(@"C:\tempuploads\NewDirectoty");

2. Directory deletion method: publicstatic void Delete (string path,bool recursive);

    1. Directory. Delete(@"c:\tempuploads\BackUp",true);

3. How to obtain all subdirectory names under the current directory: publicstatic string[] GetDirectories (string path);

    1. String [] directorys;
    2. Directorys = Directory. getdirectories (@"c:\tempuploads");

4. Get all the file names in the current directory: publicstatic string[] GetFiles (string path);

    1. String [] Files;
    2. Files = Directory. GetFiles (@"c:\tempuploads");

5. Determine if the directory exists method: publicstatic bool Exist (string path);

  1. If(File. Exists(@"c:\NewDirectory")) //Determine if the directory exists
  2. {
  3. getdirectory(); //Get sub-directories
  4. GetFile(); //Get files
  5. movedirectory(); //Mobile directory
  6. deletedirectory(); //delete directory
  7. }
  8. Else
  9. {
  10. makedirectory(); //Generate directory
  11. setdirectory(); //Set directory properties
  12. }

I/O Directory class

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.