From ed8d62deb585a9447accb0deaecc9dba52899a52 Mon Sep 17 00:00:00 2001 From: Zikirillo2002 <128654271+Zikirillo2002@users.noreply.github.com> Date: Sun, 11 Jun 2023 23:12:48 +0500 Subject: [PATCH] added 2.task2 --- HomeworksDircAndFile/Program.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/HomeworksDircAndFile/Program.cs b/HomeworksDircAndFile/Program.cs index 6fb8f0f..cbd540e 100644 --- a/HomeworksDircAndFile/Program.cs +++ b/HomeworksDircAndFile/Program.cs @@ -4,7 +4,27 @@ internal class Program { static void Main(string[] args) { - Console.WriteLine("Hello, World!"); + Console.Write("Fayl manzilini kiriting" + + "(Misol : D:\\papka nomi\\...\\ fayl nomi.txt) : "); + + string path = Console.ReadLine(); + + TextSearchLine(path); + } + + static void TextSearchLine(string path) + { + + if(File.Exists(path)) + { + Console.WriteLine($" Fayl ichidagi textni qatorlari soni :" + + $" {File.ReadAllLines(path).Length}."); + } + + else + { + Console.WriteLine($"Bunday fayl [ {path} ] mavjud emas."); + } } } } \ No newline at end of file