C # 12th Day

Source: Internet
Author: User

1. Directory Operations folder

1) Create a folder

1 directory.createdirectory (@ "c:\a"); 2             Console.WriteLine (" created successfully "); 3             Console.readkey ();
View Code

2) Delete Folder

1             Directory.delete (@ "c:\a"true); 2             Console.WriteLine (" Delete succeeded "); 3             Console.readkey ()
View Code

3) Cut folder

1             Directory.move (@ "c:\a"@ "C:\Users\SpringRain\Desktop\new" ); 2             Console.WriteLine (" Shear Success "); 3             Console.readkey ();
View Code

4) Get full path to all files (excluding folders) under the specified directory (folder)

1            string[] path = Directory.GetFiles (@"C:\Users\SpringRain\Desktop\Picture","*.jpg");2              for(inti =0; I < path. Length; i++)3             {4 Console.WriteLine (Path[i]);5             }6Console.readkey ();
View Code

5) Get the full path to all folders in the specified directory

1             string [] path = directory.getdirectories (@ "C:\Users\SpringRain\Desktop\new"); 2              for (int0; i < path.) Length; i++)3            {4                Console.WriteLine (Path[i]); 5             }6             console.readkey ();     
View Code

6) Determine if the specified folder exists

1             if(Directory.Exists (@"C:\a\b"))2             {3                  for(inti =0; I < -; i++)4                 {5Directory.CreateDirectory (@"C:\a\b\"+i);6                 }7             }8Console.WriteLine ("OK");9Console.readkey ();
View Code

C # 12th Day

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.