This commit is contained in:
2023-10-17 10:12:23 +03:00
parent ae5a52f365
commit 7a6fa0a5e4
6 changed files with 76 additions and 4 deletions

View File

@@ -1,2 +1,22 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
using System.Text;
string[] files = Directory.GetFiles("/var/data");
string maxFilePath = "";
long maxL = 0;
foreach(var filePath in files){
FileInfo fileInfo = new FileInfo(filePath);
if(fileInfo.Length > maxL){
maxL = fileInfo.Length;
maxFilePath = filePath;
}
}
using (FileStream fstream = File.OpenRead(maxFilePath)){
byte[] buffer = new byte[fstream.Length];
await fstream.ReadAsync(buffer, 0, buffer.Length);
string text = Encoding.Default.GetString(buffer);
using(FileStream fstream1 = new FileStream("/var/result/data.txt", FileMode.OpenOrCreate)){
fstream1.SetLength(0);
byte[] buffer1 = Encoding.Default.GetBytes(text);
await fstream1.WriteAsync(buffer1, 0, buffer1.Length);
}
}