Ejemplo n.º 1
0
        public static string GetValuesFromXml(string XmlFile, string valueToGet)
        {
            string value    = string.Empty;
            string filePath = Path.Combine(Directory.GetCurrentDirectory(), XmlFile);

            if (File.Exists(filePath))
            {
                using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(XmlFile))
                {
                    var setsettings = new SetSettings();
                    while (reader.Read())
                    {
                        if (reader.IsStartElement())
                        {
                            if (valueToGet == reader.Name.ToString())
                            {
                                value = reader.ReadString();
                            }
                        }
                    }
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show(new System.Windows.Forms.Form {
                    TopMost = true
                }, "Nie znaleziono pliku " + filePath, "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
            }
            return(value);
        }
Ejemplo n.º 2
0
        public static void CommitChanges()
        {
            if (File.Exists("Settings.xml"))
            {
                File.Delete("Settings.xml");
            }
            XmlWriter writer = new SetSettings().CreateSettingsFile();

            SetSettings.CreateSettingValues(writer);
            SetSettings.CloseSettingsFile(writer);
        }