Can anybody help me with the new SafeFileHandle
feature in .NET 6?
I tried this article, but the output isn't merging; only a single file.
Here's my old code using File.Create()
only:
public static async Task MergeFiles(string folderToMerge, string outputFilePath)
{
using var output = File.Create(outputFilePath);
var files = folderToMerge.EnumerateFiles("mp4");
foreach (var (i, file) in files.EnumerateWithIndex())
{
Console.WriteLine($"Merging file {i + 1} of {files.Count()}");
using var input = File.OpenRead(file);
await input.CopyToAsync(output);
}
}