Foydalanish misoli: using System;
using System.IO;
namespace Dir
{
class Program
{
publicstatic void Main(string[] args)
{
string root = @"C:\Temp";
// katalogning oxirgi yozilish vaqtini belgilash va olish
Directory.SetLastWriteTime(root, DateTime.Now);
DateTime lastWriteTime =Directory.GetLastWriteTime(root);
Console.WriteLine("So'nggi yozish sanasi va vaqti:
"+lastWriteTime);
Console.ReadKey(true);
}
}
}
Natijasi:
GetCurrentDirectory() – ilovaning joriy ishchi katalogini oladi.
SetCurrentDirectory(String) – belgilangan katalogni joriy katalog sifatida o'rnatadi.
Foydalanish misoli: using System;
using System.IO;
namespace Dir
{
class Program
{
public static void Main(string[] args)
{
string root = @"C:\Windows";
Directory.SetCurrentDirectory(root);
Console.WriteLine(Directory.GetCurrentDirectory());
Console.ReadKey(true);
}
}
}
Natijasi:
GetDirectories(String) – belgilangan katalogdagi pastki kataloglarning nomlarini (shu jumladan yo’llarini) qaytaradi.
Foydalanish misoli: using System;
using System.IO;
namespace dir
{
class Program
{
public static void Main(string[] args)
{
var docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string[] myDirs = Directory.GetDirectories(docPath);
Console.WriteLine("Kataloglar:");
foreach (var myDir in myDirs)
{
Console.WriteLine(myDir);
}
Console.ReadKey(true);
}
}
}
Natijasi:
GetDirectories(String, String) – belgilangan katalogdagi qidiruv uslubiga mos keladigan pastki kataloglarning nomlarini (shu jumladan yo’llarini) qaytaradi.
GetDirectories(String, String, SearchOption) – belgilangan katalogdagi belgilangan qidiruv namunasiga mos keladigan pastki kataloglarning nomlarini (shu jumladan yo’llarini) va ixtiyoriy ravishda pastki kataloglarni qaytaradi.