private void PlatformPrivilegeListCreator() { if (System.IO.File.Exists(privilegePath) == false) { return; } try { var doc = new System.Xml.XmlDocument(); doc.Load(privilegePath); var nodes = doc.SelectNodes("properties/entry"); var arr = nodes.OfType <XmlNode>().ToArray(); PrivilegeItems.Clear(); foreach (var arrItem in arr) { PrivilegeSupporters newItem = new PrivilegeSupporters(); newItem.privilegeName = arrItem.Attributes["key"].Value; newItem.privilegeDesc = arrItem.Attributes["desc"].Value; PrivilegeItems.Add(newItem); } } catch { } }
private static void LoadPrivilegeXml(string path) { if (System.IO.File.Exists(path) == false) { MessageBox.Show("Can not find [" + path + "]"); return; } try { var doc = new System.Xml.XmlDocument(); doc.Load(path); var nodes = doc.SelectNodes("properties/entry"); var arr = nodes.OfType <XmlNode>().ToArray(); PrivilegeItems.Clear(); foreach (var arrItem in arr) { PrivilegeSupporters newItem = new PrivilegeSupporters(); newItem.privilegeName = arrItem.Attributes["key"].Value; newItem.privilegeDesc = arrItem.Attributes["desc"].Value; PrivilegeItems.Add(newItem); } } catch { MessageBox.Show("The format of xml file is not supported"); } }
private void button_browse_Click(object sender, RoutedEventArgs e) { OpenFileDialog fDialog = new OpenFileDialog(); fDialog.DefaultExt = ".xml"; fDialog.Filter = "XML FIles (*.xml)|*.xml"; string XmlFilePath; if (fDialog.ShowDialog() == true) { XmlFilePath = fDialog.FileName; this.textbox_file.Text = XmlFilePath; if (System.IO.File.Exists(XmlFilePath) == false) { MessageBox.Show("Can not found [" + XmlFilePath + "]"); return; } var doc = new System.Xml.XmlDocument(); try { doc.Load(XmlFilePath); var nodes = doc.SelectNodes("properties/entry"); if (nodes.Count == 0) { OkBtnEnable(false); this.textbox_file.Text = string.Empty; MessageBox.Show("There is no privilege element"); return; } var arr = nodes.OfType <XmlNode>().ToArray(); this.selectPrivilegeList.Clear(); foreach (var arrItem in arr) { PrivilegeSupporters newItem = new PrivilegeSupporters(); newItem.privilegeName = arrItem.Attributes["key"].Value; this.selectPrivilegeList.Add(newItem.privilegeName); } OkBtnEnable(true); } catch { this.textbox_file.Text = string.Empty; OkBtnEnable(false); MessageBox.Show("The format of xml file is not supported"); } } }