38 lines
911 B
C#
38 lines
911 B
C#
|
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 завершена");
|