public bool WriteTree() { string configFile = FilesAndFolders.GetConfigPath(createFolder: true); var sDict = ExplicitPaths.ToSortedDictionary(); var config = new VaultEagleConfig(); try { config = ReadConfig(VaultName, VaultURI); } catch (Exception) { } string vaultId = GetVaultId(VaultName, VaultURI); config.Vaults[vaultId] = sDict; var jsonSettings = new JsonSerializerSettings() { Converters = new[] { new StringEnumConverter() } }; var json = JsonConvert.SerializeObject(config, Formatting.Indented, jsonSettings); try { using (var writer = new StreamWriter(System.IO.File.Open(configFile, FileMode.Create, FileAccess.Write))) writer.WriteLine(json); } catch { return(false); } return(true); }
public void WriteTree_Old() { string configFile = FilesAndFolders.GetConfigPath(createFolder: true); using (var writer = new StreamWriter(System.IO.File.Open(configFile, FileMode.Create, FileAccess.Write))) WriteTree_Old(writer); }
public static VaultEagleConfig ReadConfig(string vaultName, string vaultURI, bool getEmptyIfFailed = false) { string treePath = FilesAndFolders.GetConfigPath(); if (!File.Exists(treePath)) { return(new VaultEagleConfig()); } try { using (var stream = new FileStream(treePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) using (var sr = new StreamReader(stream, Encoding.UTF8)) return(ParseForest(sr, vaultName, vaultURI) ?? new VaultEagleConfig()); } catch (Exception ex) { if (getEmptyIfFailed) { return(new VaultEagleConfig()); } #if DEBUG throw new Exception("Failed to read configuration file at: '" + treePath + "'. Error: " + ex.Message, ex); #else throw new Exception("Failed to read configuration file at: '" + treePath + "'.", ex); #endif } }
public void StartSyncThread(bool showProgressWindow) { if (thread != null) { thread.Stop(); } thread = new SynchronizationThread(application, invokeControl); var log = new ProgressWindow(this, FilesAndFolders.GetLogPath()); log.Initialize(); VaultEagleSynchronizer.LogVersion(log, System.Reflection.Assembly.GetExecutingAssembly()); if (showProgressWindow) { log.Show(); } thread.logWindow = log; thread.Start(); }
private void showLogButton_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start(FilesAndFolders.GetLogPath()); }