コード例 #1
0
 public Task loadDatabase()
 {
     return(Task.Factory.StartNew(() =>
     {
         StreamReader reader = null;
         string path = LOCAL_DATABASE_PATH;
         try
         {
             if (File.Exists(path))
             {
                 reader = new StreamReader(path);
                 String json = reader.ReadToEnd();
                 LocalStorage = LocalServerStorageManagement.fillFromJson(json);
             }
             else
             {
                 throw new Exception("File Not Found");
             }
         }
         catch (Exception)
         {
         }
         finally
         {
             reader?.Close();        //close reader if not null
         }
     }));
 }
コード例 #2
0
 public Task clearDatabase()
 {
     return(Task.Factory.StartNew(() => {
         //UN REGISTER
         LocalStorage = new LocalServerStorageManagement();
         //CLEAR DISK
         try
         {
             File.Delete(LOCAL_DATABASE_PATH);
         }
         catch (Exception) { }
         isLoaded = false;
         string[] list = Directory.GetFiles(LOCAL_DATABASE_STORAGE_PATH);
         foreach (string item in list)
         {
             try
             {
                 File.Delete(item);
             }
             catch (Exception) { }
         }
     }));
 }