internal void AllReadXML() { try { XmlDocument XMLDoc = new XmlDocument(); XMLDoc.Load(fileName + @"\test.xml"); XmlNodeList XmlNodeCount = XMLDoc.GetElementsByTagName("Rental"); for (int cnode = 0; cnode <= XmlNodeCount.Count - 1; cnode++) { XmlNodeList XmlNodeRegistDay = XMLDoc.GetElementsByTagName("RegistDay"); XmlNodeList XmlNodeMediaType = XMLDoc.GetElementsByTagName("MediaType"); XmlNodeList XmlNodeTitle = XMLDoc.GetElementsByTagName("Title"); XmlNodeList XmlNodePeriod = XMLDoc.GetElementsByTagName("Period"); regist = XmlNodeRegistDay[cnode].InnerText; mediatype = XmlNodeMediaType[cnode].InnerText; title = XmlNodeTitle[cnode].InnerText; period = XmlNodePeriod[cnode].InnerText; string DisplayText; DisplayText = mediatype + " , " + title + " , " + period; MediaPeriod = period; listBox1.Items.Add(DisplayText); } if (listBox1.Items.Count == 0) { button2.Enabled = false; button3.Enabled = false; } Show(); } //catch (FileNotFoundException) //{ // XmlTextWriter SaveXML = new XmlTextWriter(fileName + @"\test.xml", null); // SaveXML.Close(); //} catch (Exception) { SaveClass tempSave = new SaveClass(); tempSave.Save(); AllReadXML(); } }
private void RentalSettingForm_FormClosing(object sender, FormClosingEventArgs e) { Save.Save(); }