// Code to execute on Unhandled Exceptions private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { // Log unhandled exception AppLogs.WriteError("App", e.ExceptionObject); if (Debugger.IsAttached) { // An unhandled exception has occurred; break into the debugger Debugger.Break(); } }
public static async Task WriteText(string fileName, string content) { try { var folder = FileSystem.Current.LocalStorage; var file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting); await file.WriteAllTextAsync(content); } catch (Exception ex) { AppLogs.WriteError("UserStorage.WriteText", ex); } }
public static async Task DeleteFileIfExists(string fileName) { try { var folder = FileSystem.Current.LocalStorage; var file = await folder.GetFileAsync(fileName); if (file != null) { await file.DeleteAsync(); } } catch (FileNotFoundException) { } catch (Exception ex) { AppLogs.WriteError("UserStorage.DeleteFileIfExists", ex); } }
public static async Task DeleteFileIfExists(string fileName) { try { var folder = ApplicationData.Current.LocalFolder; var file = await ApplicationData.Current.LocalFolder.GetFileAsync(fileName); if (file != null) { await file.DeleteAsync(StorageDeleteOption.PermanentDelete); } } catch (FileNotFoundException) { } catch (Exception ex) { AppLogs.WriteError("UserStorage.DeleteFileIfExists", ex); } }
public static async Task <string> ReadTextFromFile(string fileName) { try { var folder = FileSystem.Current.LocalStorage; var file = await folder.GetFileAsync(fileName); if (file != null) { return(await file.ReadAllTextAsync()); } } catch (FileNotFoundException) { } catch (Exception ex) { AppLogs.WriteError("UserStorage.ReadTextFromFile", ex); } return(String.Empty); }
static public string ReadTextFromFile(string fileName) { try { using (var userStorage = new UserStorage()) { lock (_userStoreLock) { if (userStorage.FileExists(fileName)) { return(userStorage.ReadText(fileName)); } } } } catch (Exception ex) { AppLogs.WriteError("UserStorage.ReadTextFromFile", ex); } return(String.Empty); }