Foydalanish misoli: DirectoryInfo di = new DirectoryInfo(@"C:\TempDir");
if (di.Exists == false)
di.Create();
DirectoryInfo dis = di.CreateSubdirectory("SubDir");
Console.WriteLine("Katalog va pastki katalog muvafaqqiyatli yaratildi.");
//True shuni ko'rsatadiki, agar ushbu katalogda pastki kataloglar
// yoki fayllar bo'lsa, ular ham o'chiriladi.
di.Delete(true);
Console.WriteLine("Katalog va pastki katalog muvafaqqiyatli o'chirildi.");
Console.ReadKey();
Natijasi: GetDirectories() – belgilangan katalogdagi pastki kataloglarning nomlarini (shu jumladan yo’llarini) qaytaradi.
Foydalanish misoli: using System;
using System.IO;
publicclass GetDirectoriesTest
{
publicstatic void Main()
{
DirectoryInfo di = new DirectoryInfo("C:\\");
DirectoryInfo[] diArr = di.GetDirectories();
Console.Write(" 'C:\\' diskdagi kataloglar:");
Console.WriteLine();
foreach (DirectoryInfo dri in diArr)
Console.WriteLine("\t" +dri.Name);
Console.ReadKey();
}
}
Natijasi:
GetDirectories(String) – belgilangan katalogdagi qidiruv uslubiga mos keladigan pastki kataloglarning nomlarini (shu jumladan yo’llarini) qaytaradi.
GetDirectories(String, SearchOption) – belgilangan katalogdagi belgilangan qidiruv namunasiga mos keladigan pastki kataloglarning nomlarini (shu jumladan yo’llarini) va ixtiyoriy ravishda pastki kataloglarni qaytaradi.
Foydalanish misoli: using System;
using System.IO;
public class GetDirectoriesTest
{
public static void Main()
{
DirectoryInfo di = new DirectoryInfo("C:\\");
DirectoryInfo[] diArr = di.GetDirectories("p*"); //("p*", SearchOption.TopDirectoryOnly)
Console.Write(" 'C:\\' diskdagi 'p' harfi bilan boshlanuvchi kataloglar:");
Console.WriteLine();