DAS_2024_1/yakovleva_yulia_lab_2/App1/Program.cs

31 lines
930 B
C#
Raw Normal View History

2024-09-20 18:36:39 +04:00
using System;
using System.IO;
class Program
{
static void Main()
{
string inputPath = Environment.GetEnvironmentVariable("DATA_PATH") ?? ".\\data";
string outputPath = Environment.GetEnvironmentVariable("RESULT_PATH") ?? ".\\result";
try
{
string[] files = Directory.GetFiles(inputPath);
using (StreamWriter writer = new StreamWriter(Path.Combine(outputPath, "data.txt")))
{
foreach (string file in files)
{
int lineCount = File.ReadAllLines(file).Length;
writer.WriteLine(lineCount);
}
}
Console.WriteLine("Файл data.txt успешно создан");
}
catch (Exception ex)
{
Console.WriteLine("Произошла ошибка: " + ex.Message);
}
}
}