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