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.");
}
}
}
Do'stlaringiz bilan baham: |