protected override void SaveInternal(SettingsObject settings) { if (!Directory.Exists(BaseDirectory)) { Directory.CreateDirectory(BaseDirectory); } var filePath = DetermineFilepath(settings); var fileExists = File.Exists(filePath); try { XmlProvider.DeepWriteToFile(DetermineFilepath(settings), settings); } catch { if (!fileExists && File.Exists(filePath)) { Tools.Exceptions.ExecuteIgnoringException(() => File.Delete(filePath)); } throw; } }