public void Save(string filename = "") { if (!string.IsNullOrEmpty(filename)) { FileInfo = new FileInfo(filename); } var imgFilename = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename) + ".img"); // Save As... if (!string.IsNullOrEmpty(filename)) { _format.Save(FileInfo.Create(), File.Create(imgFilename)); _format.Close(); } else { // Create the temp file _format.Save(File.Create(FileInfo.FullName + ".tmp"), File.Create(imgFilename + ".tmp")); _format.Close(); // Delete the original FileInfo.Delete(); File.Delete(imgFilename); // Rename the temporary file File.Move(FileInfo.FullName + ".tmp", FileInfo.FullName); File.Move(imgFilename + ".tmp", imgFilename); } // Reload the new file to make sure everything is in order Load(FileInfo.FullName); }
public bool Identify(string filename) { var imgFilename = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename) + ".img"); if (!File.Exists(filename) || !File.Exists(imgFilename)) { return(false); } try { var tmp = new DDTIMG(File.OpenRead(filename), File.OpenRead((imgFilename))); tmp.Close(); return(true); } catch (Exception) { return(false); } }
public void Unload() { _format?.Close(); }