Harry Potter and the Sorcerer's Stone


Katalogni yaratish vaqtini olish uchun C# dasturini yozing


Download 192.49 Kb.
bet57/62
Sana17.06.2023
Hajmi192.49 Kb.
#1535967
1   ...   54   55   56   57   58   59   60   61   62
Bog'liq
Algaritim amaliy-2

94. Katalogni yaratish vaqtini olish uchun C# dasturini yozing.
Javob:
using System;
namespace CatalogCreationTime
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\Users\User\Documents\Catalog";

DateTime creationTime = System.IO.Directory.GetCreationTime(path);

Console.WriteLine("Catalog yaratilgan vaqti: " + creationTime);
Console.ReadLine();
}
}
}
95. Katalogga oxirgi kirish vaqtini olish uchun C# dasturini yozing.
Javob:
using System;
namespace LastAccessTime
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\Users\User\Documents\Catalog";

DateTime lastAccessTime = System.IO.Directory.GetLastAccessTime(path);

Console.WriteLine("Catalogga oxirgi kirish vaqti: " + lastAccessTime);
Console.ReadLine();
}
}
}
96. Katalogning oxirgi yozish vaqtini olish uchun C# dasturini yozing.
Javob:
using System;
namespace LastWriteTime
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\Users\User\Documents\Catalog";

DateTime lastWriteTime = System.IO.Directory.GetLastWriteTime(path);

Console.WriteLine("Catalogning oxirgi yozish vaqti: " + lastWriteTime);
Console.ReadLine();
}
}
}
97. Asinxron tarzda yangi katalog yaratish uchun C# dasturini yozing.
Javob:
using System;
using System.IO;
using System.Threading.Tasks;
class Program
{
static async Task Main(string[] args)
{
string catalogName = "new_catalog";
if (!Directory.Exists(catalogName))
{
Directory.CreateDirectory(catalogName);
Console.WriteLine($"Katalog {catalogName} yaratildi.");
}
else
{
Console.WriteLine($"Katalog {catalogName} allaqachon mavjud.");
}
}
}


Download 192.49 Kb.

Do'stlaringiz bilan baham:
1   ...   54   55   56   57   58   59   60   61   62




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling