public bool Backup() { DirectoryInfo backupDir, dbDir; FileInfo[] files; dbDir = new DirectoryInfo(dbDirPath); backupDir = new DirectoryInfo(dbDirPath + ".backup"); try { if (backupDir.Exists) { backupDir.Delete(true); } backupDir.Create(); files = dbDir.GetFiles(); foreach (FileInfo file in files) { string temppath = Path.Combine(backupDir.FullName, file.Name); file.CopyTo(temppath, false); } projectsDB.LastBackup = DateTime.UtcNow; projectsDB.Save(); return(true); } catch (Exception ex) { Log.Exception(ex); return(false); } }
public void Reload() { projectsDB = new LiteDB(dbPath); DirectoryInfo dbDir = new DirectoryInfo(dbDirPath); foreach (FileInfo file in dbDir.GetFiles()) { if (file.FullName == dbPath) { continue; } try { Project project = Serializer.Load <Project> (file.FullName); projectsDB.Add(project.Description); } catch (Exception ex) { Log.Exception(ex); } } projectsDB.Save(); }
public void Reload() { projectsDB = new LiteDB (dbPath); DirectoryInfo dbDir = new DirectoryInfo (dbDirPath); foreach (FileInfo file in dbDir.GetFiles ()) { if (file.FullName == dbPath) { continue; } try { Project project = serializer.Load<Project> (file.FullName); projectsDB.Add (project.Description); } catch (Exception ex) { Log.Exception (ex); } } projectsDB.Save (); }