From 51e68f862862c4be2d4a5d058b93e76e8ad010dc Mon Sep 17 00:00:00 2001 From: Zikirillo2002 <128654271+Zikirillo2002@users.noreply.github.com> Date: Wed, 7 Jun 2023 00:29:07 +0500 Subject: [PATCH] Added 1.Task4 --- HomeworksDircAndFile/Program.cs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/HomeworksDircAndFile/Program.cs b/HomeworksDircAndFile/Program.cs index 6fb8f0f..70d6d25 100644 --- a/HomeworksDircAndFile/Program.cs +++ b/HomeworksDircAndFile/Program.cs @@ -1,10 +1,39 @@ -namespace HomeworksDircAndFile +using System.IO; + +namespace HomeworksDircAndFile { internal class Program { static void Main(string[] args) { - Console.WriteLine("Hello, World!"); + string path = "D:\\github darslar\\Lesson006\\.gitignore\\"; + + string[] binfind = Directory.GetDirectories(path, "bin*."); + string[] objfind = Directory.GetDirectories(path, "obj*."); + + if (!Directory.Exists(path) || + binfind.Length == 0 || + objfind.Length == 0) + { + Console.WriteLine("Bunday papka mavjud emas."); + } + + else + { + foreach (string fileInfo in binfind) + { + Console.WriteLine($"-------{fileInfo}------"); + Directory.Delete(fileInfo); + } + + foreach (string fileInfo in objfind) + { + Console.WriteLine($"-------{fileInfo}------"); + Directory.Delete(fileInfo); + } + + Console.WriteLine("Fayllar muvaffaqiyatli o'chirildi."); + } } } } \ No newline at end of file