public EditRouter(Router router,Lockifi grandparentI) { grandparent = grandparentI; InitializeComponent(); current_router = router; fileSelected = false; textBoxRoutername.Text = current_router.name; labelFile.Text = Path.GetFileName(router.file); }
public void FromXML() { string path = Directory.GetCurrentDirectory(); if (Directory.Exists(path + "\\Data")) { if (File.Exists(path + "\\Data\\users.xml")) { XmlDocument xDocUsers = new XmlDocument(); xDocUsers.Load(path + "\\Data\\users.xml"); XmlNode rootNode = xDocUsers.SelectSingleNode("/users"); string name = null; string accountId = null; foreach (XmlNode node in rootNode.ChildNodes) // for each <testcase> node { try { name = node.ChildNodes[0].InnerText; accountId = node.ChildNodes[1].InnerText; } catch (Exception e) { MessageBox.Show("Error in reading XML Data", "xmlError", MessageBoxButtons.OK); //borrar archivo } User user = new User(name, accountId); users.Add(user); user.status = false; } } if (File.Exists(path + "\\Data\\routers.xml")) { XmlDocument xDocRouters = new XmlDocument(); xDocRouters.Load(path + "\\Data\\routers.xml"); XmlNode rootNode = xDocRouters.SelectSingleNode("/routers"); string name = null; string file = null; foreach (XmlNode node in rootNode.ChildNodes) // for each <testcase> node { try { name = node.ChildNodes[0].InnerText; file = node.ChildNodes[1].InnerText; } catch (Exception e) { MessageBox.Show("Error in reading XML Data", "xmlError", MessageBoxButtons.OK); //borrar archivo } Router router = new Router(name, file); routers.Add(router); } } } }