public void Save()
{
if (track_database != null)
{
TrackDatabase.Save();
}
if (photo_database != null)
{
PhotoDatabase.Save();
}
// nothing more to do
if (equalizers == null)
{
return;
}
string backup_path = String.Format("{0}.bak", EqualizerDatabasePath);
try {
// Back up the eq db
if (File.Exists(EqualizerDatabasePath))
{
File.Copy(EqualizerDatabasePath, backup_path, true);
}
// Save the eq db
using (BinaryWriter writer = new BinaryWriter(new FileStream(EqualizerDatabasePath, FileMode.Create))) {
equalizer_container_record.Save(writer);
}
} catch (Exception e) {
// restore the backup
File.Copy(backup_path, EqualizerDatabasePath, true);
throw e;
}
}