private void ButtonAdd_Click(object sender, RoutedEventArgs e) { using (var dialog = new WinForms.FolderBrowserDialog()) { WinForms.DialogResult result = dialog.ShowDialog(); if (result == WinForms.DialogResult.OK) { BackupDirectories.Add(dialog.SelectedPath); } } }
/// <summary> /// Reads a text file encoded like below: /// 1:path /// 2:username /// 3:password /// 4:local-path /// 4: ... /// 4: local-path /// 5: excluded-path /// 5: ... /// </summary> /// <param name="file"></param> private void ReadSettings(String file) { BackupDirectories.Clear(); if (!File.Exists(file)) { return; } String line = String.Empty; using (StreamReader sr = new StreamReader(file)) { while ((line = sr.ReadLine()) != null && !String.IsNullOrEmpty(line.Trim())) { if (line.StartsWith("1:")) { TextBoxPath.Text = line.Substring(2); } else if (line.StartsWith("2:")) { TextBoxUsername.Text = line.Substring(2); } else if (line.StartsWith("3:")) { TextBoxPassword.Text = line.Substring(2); } else if (line.StartsWith("4:")) { BackupDirectories.Add(line.Substring(2)); } else if (line.StartsWith("5:")) { ExcludedDirectories.Add(line.Substring(2)); } else { throw new Exception(line); } } sr.Close(); } }