Harry Potter and the Sorcerer's Stone


Faylning oxirgi yozish vaqti uchun


Download 192.49 Kb.
bet38/62
Sana17.06.2023
Hajmi192.49 Kb.
#1535967
1   ...   34   35   36   37   38   39   40   41   ...   62
Bog'liq
Algaritim amaliy-2

9. Faylning oxirgi yozish vaqti uchun.
Javob:
using System.IO;
string filePath = "C:/example/file.txt";
DateTime lastWriteTime = File.GetLastWriteTime(filePath);
10. Fayl atributlarini olish uchun.
Javob:
using System.IO;
string filePath = "C:/example/file.txt";
FileAttributes fileAttributes= File.GetAttributes(filePath);
11. Fayl atributlarini o'rnating uchun.
Javob:
using System.IO;
string filePath = "C:/example/file.txt";
File.SetAttributes(filePath, FileAttributes.Archive | FileAttributes.Hidden);
12. Fayl nomini o'zgartirish uchun.
Javob:
using System.IO;
string oldFilePath = "C:/example/oldName.txt";
string newFilePath = "C:/example/newName.txt";
File.Move(oldFilePath, newFilePath);
13. Faylni yangi joyga ko'chirish uchun.
Javob:
using System.IO;
string sourcePath = "C:/example/sourceFile.txt";
string destinationPath = "D:/destinationFolder/destinationFile.txt";
File.Move(sourcePath, destinationPath);
14. Faylni yangi joyga nusxalash uchun.
Javob:
using System.IO;
string sourcePath = "C:/example/sourceFile.txt";
string destinationPath = "D:/destinationFolder/destinationFile.txt";
File.Copy(sourcePath, destinationPath);
15. Yangi katalog yaratish uchun.
Javob:
using System.IO;
string folderPath = "C:/example/newFolder";
Directory.CreateDirectory(folderPath);
16. Katalogni o'chirish uchun.
Javob:
using System.IO;
string folderPath = "C:/example/folderToDelete";
Directory.Delete(folderPath);
17. C# yordamida katalog mavjudligini tekshiring.
Javob:
C# da katalog mavjudligini tekshirish uchun, System.IO kutubxonasidan foydalanishingiz kerak. Quyidagi kodlar orqali siz katalog mavjudligini tekshirishingiz mumkin:
using System.IO;
string katalog_nomi = @"C:\Users\OpenAI\Desktop\Katalog";
if (Directory.Exists(katalog_nomi)) {
Console.WriteLine("Katalog mavjud!");
} else {
Console.WriteLine("Katalog mavjud emas!");
}
Bu kodlar katalog nomini `katalog_nomi` o'zgaruvchisida saqlaydi va `Directory.Exists()` metodini ishlatadi, bu metoddan qaytgan qiymat `true` bo'lsa, katalog mavjudligi tasdiqlanadi. Aks holda, katalog mavjud emasligi tasdiqlanadi.

Download 192.49 Kb.

Do'stlaringiz bilan baham:
1   ...   34   35   36   37   38   39   40   41   ...   62




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