private void openConfigurationFileToolStripMenuItem_Click(object sender, EventArgs e) { var theDialog = new OpenFileDialog { Title = @"Open Json Configuration 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 JsonExportSetting.LoadJsonConfigurationFile(chosenFile); // Update values on form LocalInitialiseJsonExtractSettings(); } } 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 FormJsonConfiguration(FormManageMetadata parent) { _myParent = parent; InitializeComponent(); // Make sure the configuration information is available in this form. try { var configurationFileName = GlobalParameters.ConfigurationPath + GlobalParameters.JsonExportConfigurationFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension; // If the config file does not exist yet, create it by calling the EnvironmentConfiguration Class if (!File.Exists(configurationFileName)) { JsonExportSetting.CreateDummyJsonConfigurationFile(configurationFileName); } // Load the validation settings file using the paths retrieved from the application root contents (configuration path) JsonExportSetting.LoadJsonConfigurationFile(configurationFileName); richTextBoxInformation.Text += $"The Json extract configuration file {configurationFileName} has been loaded."; // Apply the values to the form LocalInitialiseJsonExtractSettings(); } catch (Exception) { // Do nothing } }