forked from Alexey/DAS_2024_1
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System;
|
||
using System.IO;
|
||
|
||
class Program
|
||
{
|
||
static void Main()
|
||
{
|
||
string directoryPath = Environment.GetEnvironmentVariable("DATA_PATH") ?? ".\\data";
|
||
|
||
Random random = new Random();
|
||
|
||
try
|
||
{
|
||
if (!Directory.Exists(directoryPath))
|
||
{
|
||
Directory.CreateDirectory(directoryPath);
|
||
}
|
||
|
||
for (int i = 1; i <= 100; i++)
|
||
{
|
||
int lineCount = random.Next(1, 101);
|
||
|
||
string filePath = Path.Combine(directoryPath, $"file_{i}.txt");
|
||
|
||
using (StreamWriter writer = new StreamWriter(filePath))
|
||
{
|
||
for (int j = 0; j < lineCount; j++)
|
||
{
|
||
writer.WriteLine($"{j + 1}");
|
||
}
|
||
}
|
||
|
||
Console.WriteLine($"Файл {filePath} успешно создан с {lineCount} строками.");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Console.WriteLine("Произошла ошибка: " + ex.Message);
|
||
}
|
||
}
|
||
}
|