public static async Task<byte[]> ReadAllBytesAsync(string filename, CancellationToken cancellation = default(CancellationToken)) { using (var stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read)) { var result = new byte[stream.Length]; await stream.ReadAsync(result, 0, (int)stream.Length, cancellation); return result; } }