DAS_2024_1/dozorova_alena_lab_2/ConsoleApp1/Program.cs
2024-09-17 22:46:46 +04:00

33 lines
682 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Ищет в каталоге /var/data файл с самым коротким названием и перекладывает
// его в /var/result/data.txt.
Console.WriteLine("Start first service");
var files = Directory.GetFiles("/var/data/");
if(files == null || files.Length == 0)
{
File.Create("./var/data/data.txt");
}
string res = files[0];
files.ToList().ForEach(f =>
{
if(res.Length > f.Length)
{
res = f;
}
});
Console.WriteLine("Find file " + res);
if(!Directory.Exists("/var/result"))
{
Directory.CreateDirectory("/var/result");
}
File.Copy(res, "/var/result/data.txt");
Console.WriteLine("Copy to /var/result/data.txt");