public static UserSettings Load() { if (_settings != null) { _settings.PropertyChanged -= Settings_PropertyChanged; } if (!FileBackup.RunWithBackup(SettingsPath, () => { var json = File.ReadAllText(SettingsPath); if (String.IsNullOrEmpty(json)) { return(false); } _settings = JsonConvert.DeserializeObject <UserSettings>(json); return(true); })) { _settings = new UserSettings(); } _settings.PropertyChanged += Settings_PropertyChanged; return(_settings); }
public void FileBackup_BackupDirectory_OnBaseFiles_ShouldCreateAZipFile() { var fileBackup = new FileBackup() { SaveDirectory = new DirectoryInfo(BasePath) }; Assert.AreEqual(true, fileBackup.LoadDirectory()); Assert.AreEqual(FileBackupStatus.Loaded, fileBackup.Status); Assert.AreEqual(1, fileBackup.Characters.Count); var saveName = $"bu{DateTime.Now:yy-MM-dd-mm-ss}"; var filePath = $"{saveName}.zip"; if (File.Exists(filePath)) { File.Delete(filePath); } Console.WriteLine(filePath); Assert.AreEqual(true, fileBackup.BackUpDirectory($"{saveName}").Result); Assert.AreEqual(true, File.Exists($"{saveName}.zip")); }
private async Task <bool> InitializePlugins() { if (!Settings.ValidateAll()) { return(false); } await Async.Run(() => { IoC.Notif.ShowStatus("Removing old version..."); //remove failed / old patches Compatibility.CleanupOldVersions(); FileBackup.CleanupBackups(Configs.PatchPath); }); IoC.Notif.ShowStatus("Initializing Plugins..."); foreach (var module in Plugins) { await module.Initialize(); } _initialized = true; if (File.Exists(Configs.PatchPath)) { await LoadExistingPack(Configs.PatchPath, true); } return(true); }
static void Main(string[] args) { try { Console.WriteLine("Press any key to exit."); var fileBackup = new FileBackup(new FileBackupParameters { BackupPath = Path.Combine(Environment.CurrentDirectory, "Backup"), BackupFrequency = TimeSpan.FromSeconds(2), BackupName = "BACKUP", Expiry = TimeSpan.FromSeconds(30) }); fileBackup.Parameters.FileList.Add("file1.txt"); fileBackup.Parameters.FileList.Add("file2.txt"); fileBackup.Parameters.FileList.Add("file3.txt"); fileBackup.Start(); Console.ReadKey(true); fileBackup.Stop(); } catch (Exception ex) { Console.WriteLine("EXCEPTION: " + ex.Message); } }
public void FileBackupViewModel_OnCreation_ShouldLocateSaveFolder_IfDefault() { var fileBackup = new FileBackup(); var viewModel = new FileBackupViewModel(fileBackup); Assert.AreNotEqual(FileBackupStatus.Created, fileBackup.Status); Assert.AreNotEqual(string.Empty, viewModel.SaveDirectory); }
public Importer() { StagingDirectory = GetStagingDirectory(); Git = new Gitter(); Finder = new FileFinder(); FileSync = new FileSync(); Backup = new FileBackup(); }
public void FileBackup_Creation_ShouldBeInCreatedStatus() { var fileBackup = new FileBackup() { SaveDirectory = new DirectoryInfo(BasePath) }; Assert.AreEqual(FileBackupStatus.Created, fileBackup.Status); }
public static void WritePpd(this DissipationFile file, string path) { using (var backup = new FileBackup(path)) using (var writer = new StreamWriter(path)) { writer.WritePpd(file); backup.Delete(); } }
public void FileBackup_LoadDirectory_OnRandomPath_ShouldReturnFalse() { var fileBackup = new FileBackup() { SaveDirectory = new DirectoryInfo($"{BasePath}/NIMP") }; Assert.AreEqual(false, fileBackup.LoadDirectory()); Assert.AreEqual(FileBackupStatus.Error, fileBackup.Status); }
public void FileBackup_LoadDirectory_OnBaseFiles_ShouldDetect1Character() { var fileBackup = new FileBackup() { SaveDirectory = new DirectoryInfo(BasePath) }; Assert.AreEqual(true, fileBackup.LoadDirectory()); Assert.AreEqual(FileBackupStatus.Loaded, fileBackup.Status); Assert.AreEqual(1, fileBackup.Characters.Count); Assert.AreEqual("Bamboulorc", fileBackup.Characters.First()); }
public void FileBackupViewModel_Save_OnInvalidFolder_DoesNothing() { var fileBackup = new FileBackup(); var viewModel = new FileBackupViewModel(fileBackup); viewModel.SaveDirectory = "ndfohsdfoihsd"; Assert.AreEqual(FileBackupStatus.Error, fileBackup.Status); Assert.AreEqual(false, viewModel.IsDirectoryValid); viewModel.PerformSave(); }
public static void CleanupOldVersions() { foreach (var fileName in IoC.Config.OldVersionsToDelete) { var path = Path.Combine(Configs.GamePackDir, fileName); FileBackup.CleanupBackups(path); if (File.Exists(path)) { File.Delete(path); } } }
private void buttonBackupNow_Click(object sender, EventArgs e) { FileBackup b = new FileBackup(_playerItemDao); if (b.Backup(true)) { MessageBox.Show("Backup complete!", "Backup status", MessageBoxButtons.OK, MessageBoxIcon.Information); // TODO:TRANSLATE } else { MessageBox.Show("Backup failed, see the log file for more detailed information.", "Backup status", MessageBoxButtons.OK, MessageBoxIcon.Error); // TODO:TRANSLATE } }
private void SaveResults(List <ByteSearchResult <CharacterModel> > results) { lock (_lock) { var json = JsonConvert.SerializeObject(results, Formatting.Indented, new BaseGGUUIDConverter()); using (var fb = new FileBackup(ResultsFile)) { File.WriteAllText(ResultsFile, json); fb.Delete(); } } }
private void ExecuteInternal() { var lastSync = _settings.GetLocal().LastCharSyncUtc; var highestTimestamp = FileBackup.GetHighestCharacterTimestamp(); var characters = FileBackup.ListCharactersNewerThan(lastSync); bool everythingSucceeded = true; foreach (var c in characters) { Logger.Info($"Backup up character {c} to the cloud"); var filename = Path.Combine(GlobalPaths.CharacterBackupLocation, $"{DateTime.Now.DayOfWeek}-{c}.zip"); FileBackup.BackupCharacter(filename, c); // TODO: IOException var url = $"{Uris.UploadCharacterUrl}?name={WebUtility.UrlEncode(c)}"; var success = Post(url, filename); if (success) { Logger.Info($"Character {c} successfully backed up to the cloud"); } else { Logger.Info($"An error occurred backing up character {c} to the cloud"); everythingSucceeded = false; } } if (FileBackup.IsStashFilesNewerThan(lastSync)) { var filename = Path.Combine(GlobalPaths.CharacterBackupLocation, $"{DateTime.Now.DayOfWeek}-common.zip"); FileBackup.BackupCommon(filename); var url = $"{Uris.UploadCharacterUrl}?name=StashFiles-{DateTime.Now.DayOfWeek}"; var success = Post(url, filename); if (success) { Logger.Info($"Stash files successfully backed up to the cloud"); } else { Logger.Info($"An error occurred backing up stash files to the cloud"); everythingSucceeded = false; } } if (everythingSucceeded) { Logger.Info($"Character sync complete, updating character sync timestamp"); _settings.GetLocal().LastCharSyncUtc = highestTimestamp; } }
private static void BuildCubeFile() { CubeExtractor cbld = new CubeExtractor { ModelFileCount = cubeFiles.Length, ModelFileSize = 10, // fileCount, FileSize, filename Size ModelFilenameSize = 0x104, MaxFilenameLengthPlusSize = 0x108 }; for (int i = 0; i < cubeFiles.Length; i++) { cbld.ModelFileSize += cbld.MaxFilenameLengthPlusSize; cbld.ModelFileNames.Add(cubeFiles[i]); using (var inFile = File.OpenRead(cubeFolder + "\\" + cubeFiles[i])) using (var binaryReader = new BinaryReader(inFile)) { var inputData = binaryReader.ReadBytes((int)binaryReader.BaseStream.Length); cbld.ModelFiles.Add(cubeFiles[i], inputData); cbld.ModelFileSize += inputData.Length; inFile.Close(); } } FileBackup.MakeBackup(cubeFilename, 5); using (var outFile = File.OpenWrite(cubeFilename)) using (var binaryWriter = new BinaryWriter(outFile)) { binaryWriter.Write(cbld.ModelFileCount); binaryWriter.Write(cbld.ModelFileSize); binaryWriter.Write(cbld.MaxFilenameLengthPlusSize); foreach (String fname in cbld.ModelFileNames) { Byte[] fnameData = new byte[cbld.ModelFilenameSize]; Byte[] fnameBytes = Encoding.ASCII.GetBytes(fname); int fnameLength = cbld.ModelFilenameSize <= fnameBytes.Length ? cbld.ModelFilenameSize : fnameBytes.Length; Array.Copy(fnameBytes, fnameData, fnameLength); binaryWriter.Write(cbld.ModelFiles[fname].Length); binaryWriter.Write(fnameData, 0, cbld.ModelFilenameSize); binaryWriter.Write(cbld.ModelFiles[fname]); } outFile.Close(); } }
private bool CreatePatch() { //remove failed patches FileBackup.CleanupBackups(Configs.PatchPath); using (var oldPatch = new FileBackup(Configs.PatchPath)) { var patcher = new Patcher(); var patch = patcher.StartPatch(); foreach (var module in Plugins) { IoC.Notif.ShowStatus($"Generating patch ({module.PluginName})..."); module.ApplyChanges(patch); } IoC.Notif.ShowStatus("Generating plugin patches..."); patcher.ApplyCustomPatches(patch, PluginManager); IoC.Notif.ShowStatus("Generating patch (rebuild prefetch)..."); var p = Prefetch.Load(patch); if (p.Rebuild(patch)) { p.Save(); } if (!Directory.Exists(patch.WorkingDir)) { IoC.Notif.ShowStatus("No changes found, aborting pack creation."); return(false); } IoC.Notif.ShowStatus("Generating patch (packing)..."); patcher.PackPatch(patch); IoC.Notif.ShowStatus("Copying patch..."); patcher.InstallPatch(patch); oldPatch.Delete(); #if !DEBUG Paths.Cleanup(IoC.Config.TempPath); #endif } return(true); }
public void Test_Backup() { new FilesGrabber(OriginalDirectory, CurrentDirectory) .GrabOriginalFiles(); var testFile = Path.GetFullPath("test.txt"); File.WriteAllText(testFile, "Test content"); var filePath = new FileBackup().Backup(testFile); Console.WriteLine("Backup file path: " + filePath); var ext = Path.GetExtension(filePath); Assert.AreEqual(".bak", ext, ".bak extension wasn't applied"); }
/// <summary> /// 修改 variable.txt /// </summary> /// <param name="relocalizeLanguage">新的语言</param> /// <param name="relocalizeAsset">新的语音包</param> public static void ChangeVarTXT(String relocalizeLanguage, String relocalizeAsset) { try { String sc2VarLocation = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\StarCraft II\\Variables.txt"; FileBackup.MultipleBackup(sc2VarLocation, 4);//备份文件 //如果文件不存在,创建一个 if (!File.Exists(sc2VarLocation)) { File.Create(sc2VarLocation); } //如果文件只读,取消只读 FileInfo fInfo = new FileInfo(sc2VarLocation); if (fInfo.IsReadOnly) { fInfo.IsReadOnly = false; } String text = File.ReadAllText(sc2VarLocation); //如果localeidassets不存在 if (text.IndexOf("localeidassets=") == -1) { text = text + "localeidassets=" + relocalizeAsset + "\r\n"; File.WriteAllText(sc2VarLocation, text); } //如果localeiddata不存在 if (text.IndexOf("localeiddata=") == -1) { text = text + "localeiddata=" + relocalizeLanguage + "\r\n"; File.WriteAllText(sc2VarLocation, text); } text = ReplaceText.ReplaceAfterSearchString(text, "localeiddata=", 4, relocalizeLanguage); text = ReplaceText.ReplaceAfterSearchString(text, "localeidassets=", 4, relocalizeAsset); File.WriteAllText(sc2VarLocation, text); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private List <ByteSearchResult <CharacterModel> > LoadResults() { lock (_lock) { List <ByteSearchResult <CharacterModel> > results = null; FileBackup.RunWithBackup(ResultsFile, () => { if (!File.Exists(ResultsFile)) { return(false); } var json = File.ReadAllText(ResultsFile); results = JsonConvert.DeserializeObject <List <ByteSearchResult <CharacterModel> > >(json, new BaseGGUUIDConverter()); return(true); }); return(results); } }
private static void DecodeCubeFile() { Encoding encoding = Encoding.ASCII; if (cube3File != null || cube3File.Length > 0) { try { using (var inFile = File.OpenRead(cube3File)) using (var binaryReader = new BinaryReader(inFile)) { var inputCubeFile = binaryReader.ReadBytes((int)binaryReader.BaseStream.Length); CubeExtractor ce = new CubeExtractor(inputCubeFile); foreach (String filename in ce.ModelFiles.Keys) { String directory = Path.GetDirectoryName(filename); if (directory.Length > 0) { Directory.CreateDirectory(directory); } FileBackup.MakeBackup(filename, 5); using (var outFile = File.OpenWrite(filename)) using (var binaryWriter = new BinaryWriter(outFile)) { binaryWriter.Write(ce.ModelFiles[filename]); outFile.Close(); } } } } catch (Exception ex) { System.Console.WriteLine($"Exception thrown {ex.Message}"); } } }
private static void Save(UserSettings settings) { try { _lock.Wait(); Paths.CheckDirectory(ApplicationSettingsPath); using var backup = new FileBackup(SettingsPath); var json = JsonConvert.SerializeObject(settings, Formatting.Indented); File.WriteAllText(SettingsPath, json); backup.Delete(); } finally { _lock.Release(); } }
private void buttonBackupNow_Click(object sender, EventArgs e) { var fileBackup = new FileBackup(_playerItemDao); if (fileBackup.Backup(true)) { MessageBox.Show( GlobalSettings.Language.GetTag("iatag_ui_backup_complete"), GlobalSettings.Language.GetTag("iatag_ui_backup_status"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show( GlobalSettings.Language.GetTag("iatag_ui_backup_failed"), GlobalSettings.Language.GetTag("iatag_ui_backup_status"), MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void UpdateDatabase(int versionFrom, int versionTo) { FileBackup.BackupWithTime(Info.GetDirectory() + "\\data.db"); SQLite sqlite = new SQLite("data.db"); switch (versionTo) { case 2: sqlite.AddColumns(LIST_FAMILIES_TABLE_NAME, new List <string> { FIELD_NAME_SHOW_FINISHED_ITEM, FIELD_NAME_SHOW_ABANDONED_ITEM, FIELD_NAME_SHOW_OVERDUE_ITEM, FIELD_NAME_SORT_TYPE }, new List <string> { "INTEGER", "INTEGER", "INTEGER", "INTEGER" }); sqlite.Update(LIST_FAMILIES_TABLE_NAME, new List <string> { FIELD_NAME_SHOW_FINISHED_ITEM, FIELD_NAME_SHOW_ABANDONED_ITEM, FIELD_NAME_SHOW_OVERDUE_ITEM, FIELD_NAME_SORT_TYPE }, new List <string> { "1", "0", "1", "1" }, "list_family_id > '0'"); break; } }
public void FileBackup_RestoreDirectory_OnBaseFiles_ShouldRestoreThemProperly() { var fileBackup = new FileBackup() { SaveDirectory = new DirectoryInfo(BasePath) }; Assert.AreEqual(true, fileBackup.LoadDirectory()); Assert.AreEqual(FileBackupStatus.Loaded, fileBackup.Status); Assert.AreEqual(1, fileBackup.Characters.Count); var saveName = $"bu{DateTime.Now:yy-MM-dd-mm-ss}"; var filePath = $"{saveName}.zip"; if (File.Exists(filePath)) { File.Delete(filePath); } Assert.AreEqual(true, fileBackup.BackUpDirectory($"{saveName}").Result); Assert.AreEqual(true, File.Exists(filePath)); new DirectoryInfo(BasePath).Delete(true); var reloadFb = new FileBackup() { SaveDirectory = new DirectoryInfo(BasePath) }; Assert.AreEqual(false, reloadFb.LoadDirectory()); Assert.AreEqual(true, fileBackup.RestoreDirectory(source: filePath).Result); Assert.AreEqual(true, reloadFb.LoadDirectory()); Assert.AreEqual(FileBackupStatus.Loaded, reloadFb.Status); Assert.AreEqual(1, reloadFb.Characters.Count); Assert.AreEqual("Bamboulorc", reloadFb.Characters.First()); }
public void LoadFromFile(IniFile ini) { if (ini == null) { throw new ArgumentNullException("ini"); } int optsVersion = ini.ReadInteger("Common", "OptsVersion", 0); fDefNameFormat = (NameFormat)ini.ReadInteger("Common", "DefNameFormat", 0); fDefDateFormat = (DateFormat)ini.ReadInteger("Common", "DefDateFormat", 0); fLastDir = ini.ReadString("Common", "LastDir", ""); fPlacesWithAddress = ini.ReadBool("Common", "PlacesWithAddress", false); fShowTips = ini.ReadBool("Common", "ShowTips", true); fInterfaceLang = (ushort)ini.ReadInteger("Common", "InterfaceLang", 0); fFileBackup = (FileBackup)ini.ReadInteger("Common", "FileBackup", 0); fShowDatesCalendar = ini.ReadBool("Common", "ShowDatesCalendar", false); fShowDatesSign = ini.ReadBool("Common", "ShowDatesSigns", false); fRemovableMediaWarning = ini.ReadBool("Common", "RemovableMediaWarning", true); fLoadRecentFiles = ini.ReadBool("Common", "LoadRecentFiles", true); fEmbeddedMediaPlayer = ini.ReadBool("Common", "EmbeddedMediaPlayer", true); fAllowMediaStoreReferences = ini.ReadBool("Common", "AllowMediaStoreReferences", false); fAllowMediaStoreRelativeReferences = ini.ReadBool("Common", "AllowMediaStoreRelativeReferences", true); // only when AllowMediaStoreReferences is true fMediaStoreDefault = (ushort)ini.ReadInteger("Common", "MediaStoreDefault", 0); // (int)MediaStoreType.mstReference fAllowDeleteMediaFileFromStgArc = ini.ReadBool("Common", "AllowDeleteMediaFileFromStgArc", true); fAllowDeleteMediaFileFromRefs = ini.ReadBool("Common", "AllowDeleteMediaFileFromRefs", false); fDeleteMediaFileWithoutConfirm = ini.ReadBool("Common", "DeleteMediaFileWithoutConfirm", false); fAutoCheckUpdates = ini.ReadBool("Common", "AutoCheckUpdates", true); fAutoSortChildren = ini.ReadBool("Common", "AutoSortChildren", true); fAutoSortSpouses = ini.ReadBool("Common", "AutoSortSpouses", false); fCharsetDetection = ini.ReadBool("Common", "CharsetDetection", false); fAutosave = ini.ReadBool("Common", "Autosave", false); fAutosaveInterval = ini.ReadInteger("Common", "AutosaveInterval", 10); fExtendedNames = ini.ReadBool("Common", "ExtendedNames", false); fWomanSurnameFormat = (WomanSurnameFormat)ini.ReadInteger("Common", "WomanSurnameFormat", 0); fGeocoder = ini.ReadString("Common", "Geocoder", "Google"); int kl = ini.ReadInteger("Common", "KeyLayout", AppHost.Instance.GetKeyLayout()); AppHost.Instance.SetKeyLayout(kl); fTreeChartOptions.LoadFromFile(ini); fPedigreeOptions.LoadFromFile(ini); fProxy.LoadFromFile(ini); int cnt = ini.ReadInteger("NameFilters", "Count", 0); for (int i = 0; i < cnt; i++) { string st = ini.ReadString("NameFilters", "Filter_" + i.ToString(), ""); if (st != "") { fNameFilters.Add(st); } } cnt = ini.ReadInteger("ResidenceFilters", "Count", 0); for (int i = 0; i < cnt; i++) { fResidenceFilters.Add(ini.ReadString("ResidenceFilters", "Filter_" + i.ToString(), "")); } cnt = ini.ReadInteger("EventFilters", "Count", 0); for (int i = 0; i < cnt; i++) { fEventFilters.Add(ini.ReadString("EventFilters", "EventVal_" + i.ToString(), "")); } LoadMRUFromFile(ini, fMRUFiles); cnt = ini.ReadInteger("Relations", "Count", 0); for (int i = 0; i < cnt; i++) { fRelations.Add(ini.ReadString("Relations", "Relation_" + i.ToString(), "")); } fIndividualListColumns.LoadFromFile(ini, "PersonsColumns"); fListHighlightUnmarriedPersons = ini.ReadBool("ListPersons", "HighlightUnmarried", false); fListHighlightUnparentedPersons = ini.ReadBool("ListPersons", "HighlightUnparented", false); fMWinRect.Left = ini.ReadInteger("Common", "MWinL", -1); fMWinRect.Top = ini.ReadInteger("Common", "MWinT", -1); fMWinRect.Right = ini.ReadInteger("Common", "MWinW", -1); fMWinRect.Bottom = ini.ReadInteger("Common", "MWinH", -1); fMWinState = (WindowState)((uint)ini.ReadInteger("Common", "MWinState", 0)); cnt = ini.ReadInteger("LastBases", "Count", 0); for (int i = 0; i < cnt; i++) { string st = ini.ReadString("LastBases", "LB" + i.ToString(), ""); AddLastBase(st); } fCircleChartOptions.LoadFromFile(ini); fListOptions.LoadFromFile(ini); LoadPluginsFromFile(ini); }
// Import data from a CSV file. Display instructions and error messages as needed. private async void MenuItemImportFromCsv_Click(object sender, RoutedEventArgs e) { if (this.State.SuppressCsvImportPrompt == false) { // Tell the user how importing CSV files work. Give them the opportunity to abort. if (Dialogs.MenuFileHowImportingCSVWorksDialog(this) == false) { return; } } string csvFileName = Path.GetFileNameWithoutExtension(this.DataHandler.FileDatabase.FileName) + Constant.File.CsvFileExtension; if (Dialogs.TryGetFileFromUserUsingOpenFileDialog( "Select a .csv file to merge into the current image set", Path.Combine(this.DataHandler.FileDatabase.FolderPath, csvFileName), String.Format("Comma separated value files (*{0})|*{0}", Constant.File.CsvFileExtension), Constant.File.CsvFileExtension, out string csvFilePath) == false) { return; } // Create a backup database file if (FileBackup.TryCreateBackup(this.FolderPath, this.DataHandler.FileDatabase.FileName)) { this.StatusBar.SetMessage("Backup of data file made."); } else { this.StatusBar.SetMessage("No data file backup was made."); } try { // Show the Busy indicator this.BusyCancelIndicator.IsBusy = true; Tuple <bool, List <string> > resultAndImportErrors; resultAndImportErrors = await CsvReaderWriter.TryImportFromCsv(csvFilePath, this.DataHandler.FileDatabase).ConfigureAwait(true); this.BusyCancelIndicator.IsBusy = false; if (resultAndImportErrors.Item1 == false) { // Can't import CSV File Dialogs.MenuFileCantImportCSVFileDialog(this, Path.GetFileName(csvFilePath), resultAndImportErrors.Item2); } else { // Importing done. Dialogs.MenuFileCSVFileImportedDialog(this, Path.GetFileName(csvFilePath)); // Reload the data this.BusyCancelIndicator.IsBusy = true; await this.FilesSelectAndShowAsync().ConfigureAwait(true); this.BusyCancelIndicator.IsBusy = false; this.StatusBar.SetMessage("CSV file imported."); } } catch (Exception exception) { // Can't import the .csv file Dialogs.MenuFileCantImportCSVFileDialog(this, Path.GetFileName(csvFilePath), exception.Message); } }
public InstallUnpacker() { FileFinder = new FileFinder(); Backup = new FileBackup(); }
public FileSync() { Finder = new FileFinder(); FileBackup = new FileBackup(); }
// Export data for this image set as a .csv file // Export data for this image set as a .csv file and preview in Excel private void MenuItemExportCsv_Click(object sender, RoutedEventArgs e) { if (this.State.SuppressSelectedCsvExportPrompt == false && this.DataHandler.FileDatabase.ImageSet.FileSelection != FileSelectionEnum.All) { // Export data for this image set as a.csv file, but confirm, as only a subset will be exported since a selection is active if (Dialogs.MenuFileExportCSVOnSelectionDialog(this) == false) { return; } } // Generate the file names/path string csvFileName = Path.GetFileNameWithoutExtension(this.DataHandler.FileDatabase.FileName) + ".csv"; string csvFilePath = Path.Combine(this.FolderPath, csvFileName); // Backup the csv file if it exists, as the export will overwrite it. if (FileBackup.TryCreateBackup(this.FolderPath, csvFileName)) { this.StatusBar.SetMessage("Backup of csv file made."); } else { this.StatusBar.SetMessage("No csv file backup was made."); } try { CsvReaderWriter.ExportToCsv(this.DataHandler.FileDatabase, csvFilePath, this.excludeDateTimeAndUTCOffsetWhenExporting); } catch (IOException exception) { // Can't write the spreadsheet file Dialogs.MenuFileCantWriteSpreadsheetFileDialog(this, csvFilePath, exception.GetType().FullName, exception.Message); return; } MenuItem mi = (MenuItem)sender; if (mi == this.MenuItemExportAsCsvAndPreview) { // Show the file in excel // Create a process that will try to show the file ProcessStartInfo processStartInfo = new ProcessStartInfo { UseShellExecute = true, RedirectStandardOutput = false, FileName = csvFilePath }; if (ProcessExecution.TryProcessStart(processStartInfo) == false) { // Can't open excel Dialogs.MenuFileCantOpenExcelDialog(this, csvFilePath); return; } } else if (this.State.SuppressCsvExportDialog == false) { Dialogs.MenuFileCSVDataExportedDialog(this, csvFileName); } this.StatusBar.SetMessage("Data exported to " + csvFileName); }