using System; using System.Threading.Tasks; using Windows.Storage; using Windows.Storage.Streams; namespace Wino.Helpers { // Use these extension methods to store and retrieve local and roaming app data // More details regarding storing and retrieving app data at https://docs.microsoft.com/windows/uwp/app-settings/store-and-retrieve-app-data public static class SettingsStorageExtensions { public static async Task ReadBytesAsync(this StorageFile file) { if (file != null) { using (IRandomAccessStream stream = await file.OpenReadAsync()) { using (var reader = new DataReader(stream.GetInputStreamAt(0))) { await reader.LoadAsync((uint)stream.Size); var bytes = new byte[stream.Size]; reader.ReadBytes(bytes); return bytes; } } } return null; } } }