예제 #1
0
        // 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();
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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);
        }
예제 #6
0
 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);
 }