/// <summary> /// Validate the OutputFilePath, and if this is not correct it will be set to the default /// Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is /// used on a different PC) /// </summary> public static void ValidateAndCorrectOutputFilePath(this ICoreConfiguration coreConfiguration) { if (!Directory.Exists(coreConfiguration.OutputFilePath)) { coreConfiguration.RestoreToDefault("OutputFilePath"); } }
/// <summary> /// Validate the OutputFileAsFullpath, and if this is not correct it will be set to the default /// Added for BUG-1992, reset the OutputFilePath / OutputFileAsFullpath if they don't exist (e.g. the configuration is /// used on a different PC) /// </summary> public static void ValidateAndCorrectOutputFileAsFullpath(this ICoreConfiguration coreConfiguration) { var outputFilePath = Path.GetDirectoryName(coreConfiguration.OutputFileAsFullpath); if (outputFilePath == null || !File.Exists(coreConfiguration.OutputFileAsFullpath) && !Directory.Exists(outputFilePath)) { coreConfiguration.RestoreToDefault("OutputFileAsFullpath"); } }
/// <summary> /// Validate the values in the ICoreConfiguration, correct them where needed /// </summary> public static void ValidateAndCorrect(this ICoreConfiguration coreConfiguration) { if (string.IsNullOrEmpty(coreConfiguration.OutputFileFilenamePattern)) { coreConfiguration.RestoreToDefault(nameof(ICoreConfiguration.OutputFileFilenamePattern)); } if (!Directory.Exists(coreConfiguration.OutputFilePath)) { coreConfiguration.RestoreToDefault(nameof(ICoreConfiguration.OutputFilePath)); } if (string.IsNullOrEmpty(coreConfiguration.OutputFilePath)) { coreConfiguration.OutputFilePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); } var outputFilePath = Path.GetDirectoryName(coreConfiguration.OutputFileAsFullpath); if (outputFilePath == null || !File.Exists(coreConfiguration.OutputFileAsFullpath) && !Directory.Exists(outputFilePath)) { coreConfiguration.RestoreToDefault(nameof(ICoreConfiguration.OutputFileAsFullpath)); } }