2023-10-18 10:45:47 +04:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
2023-12-02 10:45:25 +04:00
|
|
|
|
string[] files = Directory.GetFiles("/var/data");
|
2023-10-18 10:45:47 +04:00
|
|
|
|
string minFilePath = "";
|
|
|
|
|
long minFileNameLength = long.MaxValue;
|
|
|
|
|
foreach (var filePath in files)
|
|
|
|
|
{
|
|
|
|
|
FileInfo fileInfo = new FileInfo(filePath);
|
|
|
|
|
string fileName = Path.GetFileName(filePath);
|
|
|
|
|
|
|
|
|
|
if (fileName.Length < minFileNameLength)
|
|
|
|
|
{
|
|
|
|
|
minFileNameLength = fileName.Length;
|
|
|
|
|
minFilePath = filePath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
using (FileStream sourceStream = File.OpenRead(minFilePath))
|
|
|
|
|
{
|
|
|
|
|
byte[] buffer = new byte[sourceStream.Length];
|
|
|
|
|
await sourceStream.ReadAsync(buffer, 0, buffer.Length);
|
|
|
|
|
string text = Encoding.Default.GetString(buffer);
|
|
|
|
|
|
2023-12-02 10:45:25 +04:00
|
|
|
|
using (FileStream targetStream = new FileStream("/var/result/data.txt", FileMode.OpenOrCreate))
|
2023-10-18 10:45:47 +04:00
|
|
|
|
{
|
|
|
|
|
targetStream.SetLength(0);
|
|
|
|
|
byte[] textBytes = Encoding.Default.GetBytes(text);
|
|
|
|
|
await targetStream.WriteAsync(textBytes, 0, textBytes.Length);
|
|
|
|
|
}
|
|
|
|
|
}
|