public LoadResult Load(string filename, bool autoBackup = false) { LoadResult result = LoadResult.Success; FileInfo = new FileInfo(filename); _entries = null; if (FileInfo.Exists) { var ident = Support.Identify(filename); switch (ident) { case Ident.v1: _gmd = new GMDv1(); _gmdBackup = new GMDv1(); break; case Ident.v2: _gmd = new GMDv2(); _gmdBackup = new GMDv2(); break; } _gmd.Load(filename); OpenOrCreateBackup(autoBackup); } else { result = LoadResult.FileNotFound; } return(result); }
private void OpenOrCreateBackup(bool autoBackup) { var backupFilePath = FileInfo.FullName + ".bak"; if (File.Exists(backupFilePath)) { _gmdBackup.Load(backupFilePath); } else if (autoBackup || MessageBox.Show("Would you like to create a backup of " + FileInfo.Name + "?\r\nA backup allows the Original text box to display the source text before edits were made.", "Create Backup", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { File.Copy(FileInfo.FullName, backupFilePath); _gmdBackup.Load(backupFilePath); } else { _gmdBackup = null; } }