Convert Storage File to Byte Array in Universal Windows apps

This async function converts a storage file to a byte array. public static async Task<byte[]> GetBytesAsync(StorageFile file) { byte[] fileBytes = null; if (file == null) return null; using (var stream = await file.OpenReadAsync()) { fileBytes = new byte[stream.Size]; using (var reader = new DataReader(stream)) { await reader.LoadAsync((uint)stream.Size); reader.ReadBytes(fileBytes); } } return fileBytes; } It […]

Read More