public void Save(string filename) { if (!string.IsNullOrEmpty(filename)) { FileInfo = new FileInfo(filename); } var hpiFilename = FileInfo.FullName; var hpbFilename = FileInfo.FullName.Remove(FileInfo.FullName.Length - 1) + "B"; // Save As... if (!string.IsNullOrWhiteSpace(filename)) { _hpihpb.Save(File.Create(hpiFilename), File.Create(hpbFilename)); _hpihpb.Dispose(); } else { // Create the temp files _hpihpb.Save(File.Create(hpiFilename + ".tmp"), File.Create(hpbFilename + ".tmp")); _hpihpb.Dispose(); // Delete the originals FileInfo.Delete(); File.Delete(hpbFilename); // Rename the temporary files File.Move(hpiFilename + ".tmp", hpiFilename); File.Move(hpbFilename + ".tmp", hpbFilename); } // Reload the new file to make sure everything is in order Load(FileInfo.FullName); }
public SaveResult Save(string filename) { SaveResult result = SaveResult.Success; if (!string.IsNullOrWhiteSpace(filename)) { _fileInfo = new FileInfo(filename); } var hpiFilename = _fileInfo.FullName; var hpbFilename = _fileInfo.FullName.Remove(_fileInfo.FullName.Length - 1) + "B"; try { // Save As... if (!string.IsNullOrWhiteSpace(filename)) { _hpihpb.Save(File.Create(hpiFilename), File.Create(hpbFilename)); _hpihpb.Dispose(); } else { // Create the temp files _hpihpb.Save(File.Create(hpiFilename + ".tmp"), File.Create(hpbFilename + ".tmp")); _hpihpb.Dispose(); // Delete the originals _fileInfo.Delete(); File.Delete(hpbFilename); // Rename the temporary files File.Move(hpiFilename + ".tmp", hpiFilename); File.Move(hpbFilename + ".tmp", hpbFilename); } // Reload the new file to make sure everything is in order Load(_fileInfo.FullName); } catch { result = SaveResult.Failure; } return(result); }
public void Unload() { _hpihpb?.Dispose(); }