khteh
khteh

Reputation: 3892

.Net Core 7 System.CommandLine.RootCommand.SetHandler fileinfo ReadAllBytesAsync

Is there any way to read from FileInfo to byte[]?

   rootCommand.SetHandler(async (file) =>
        {
            if (!file.Exists)
                throw new InvalidOperationException($"Invalid input file: {file.Name}");
            using var package = new ExcelPackage(file);
            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
            ExcelWorksheets worksheets = package.Workbook.Worksheets;
            if (!worksheets.Any())
                throw new InvalidOperationException($"Invalid empty {file.Name}");
            byte[] data = await System.IO.File.ReadAllBytesAsync(file); <= XXX here. How to read from FileInfo to byte[]?

Upvotes: 0

Views: 256

Answers (0)

Related Questions