private void openConfigurationFileToolStripMenuItem_Click(object sender, EventArgs e) { var theDialog = new OpenFileDialog { Title = @"Open Validation File", Filter = @"Text files|*.txt", InitialDirectory = @"" + GlobalParameters.ConfigurationPath + "" }; if (theDialog.ShowDialog() != DialogResult.OK) { return; } try { var myStream = theDialog.OpenFile(); using (myStream) { richTextBoxInformation.Clear(); var chosenFile = theDialog.FileName; // Load from disk into memory ValidationSetting.LoadValidationFile(chosenFile); // Update values on form LocalInitialiseValidationSettings(); } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message, "An issues has been encountered", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public FormManageValidation(FormManageMetadata parent) { _myParent = parent; InitializeComponent(); // Make sure the validation information is available in this form. try { var validationFile = GlobalParameters.ConfigurationPath + GlobalParameters.ValidationFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension; // If the config file does not exist yet, create it by calling the EnvironmentConfiguration Class if (!File.Exists(validationFile)) { ValidationSetting.CreateDummyValidationFile(validationFile); } // Load the validation settings file using the paths retrieved from the application root contents (configuration path) ValidationSetting.LoadValidationFile(validationFile); richTextBoxInformation.Text += $@"The validation file {validationFile} has been loaded."; // Apply the values to the form LocalInitialiseValidationSettings(); } catch (Exception) { // Do nothing } }