public class DataStorage { public async Task WriteFile(string key, object value) { try { var jsonValue = JsonConvert.SerializeObject(value); using (var file = await folder.OpenStreamForWriteAsync(key, CreationCollisionOption.ReplaceExisting)) using (var stream = new StreamWriter(file)) await stream.WriteAsync(jsonValue); } catch (Exception exception) { AsyncErrorHandler.HandleException(exception); } } }
public static class AsyncErrorHandler { public static void HandleException(Exception exception) { Debug.WriteLine(exception); } }
https://github.com/Fody/AsyncErrorHandler/blob/master/README.md
时间: 2024-10-11 14:46:34