public static List <OtherExeContainer> readArrayFromXML() { List <OtherExeContainer> exeArray = new List <OtherExeContainer>(); //If the XML file is not empty... if (System.IO.File.ReadAllText(ConfigForm.getXmlLocation()).ToString() != "") { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(ConfigForm.getXmlLocation()); XmlNodeList exeNodes = xmlDoc.SelectNodes("//Executables/OtherExes"); foreach (XmlNode exeNode in exeNodes) { if (exeNode.HasChildNodes) { OtherExeContainer oExeContainer = new OtherExeContainer(); oExeContainer.setExe(exeNode["OtherExe"].InnerText); oExeContainer.setParam(exeNode["OtherExe"].Attributes["Params"].Value); exeArray.Add(oExeContainer); } } return(exeArray); } return(exeArray); }
private void browseNewAppBtn_Click(Object sender, System.EventArgs e) { OpenFileDialog newAppDialog = new OpenFileDialog(); newAppDialog.Filter = "Exe files (*.exe)|*.exe|All files (*.*)|*.*"; DialogResult result = newAppDialog.ShowDialog(); // Show the dialog. if (result == DialogResult.OK) // Test result. { ProgramLauncher.CustomClasses.OtherExeContainer oEC = new CustomClasses.OtherExeContainer(); oEC.setExe(addNewAppTbx.Text); ConfigForm.deleteExeFromArray(oEC); string file = newAppDialog.FileName; try { if (!file.ToLower().Equals(ConfigForm.EXE_PATH.ToLower())) { oEC.setExe(file); oEC.setParam(addNewAppTbx.Text); if (ConfigForm.setOtherExesArray(oEC)) { addNewAppTbx.Text = file; } } else { MessageBox.Show(ConfigForm.EXE_PATH + " is not a valid executable, please choose a different application."); } } catch (IOException) { } } }