distributed-computing/tasks/mytarin_es/lab2/worker-1/Program.cs

38 lines
911 B
C#
Raw Normal View History

2023-10-09 23:26:37 +04:00
using System.Text;
string[] f = Directory.GetFiles("../var/data");
string maxPath = "";
long maxCapacity = 0;
foreach (var path in f)
{
FileInfo info = new FileInfo(path);
if (info.Length > maxCapacity)
{
maxCapacity = info.Length;
maxPath = path;
}
}
using (FileStream stream_read = File.OpenRead(maxPath))
{
byte[] bufffer_read = new byte[stream_read.Length];
await stream_read.ReadAsync(bufffer_read, 0, bufffer_read.Length);
string text = Encoding.Default.GetString(bufffer_read);
using (FileStream stream_write = new FileStream("../var/result/data.txt", FileMode.OpenOrCreate))
{
stream_write.SetLength(0);
byte[] buffer_write = Encoding.Default.GetBytes(text);
await stream_write.WriteAsync(buffer_write, 0, buffer_write.Length);
}
}
Console.WriteLine("Программа 1 завершена");