public static ConfigXml Load(FileInfo fileInfo) { try { if (fileInfo == null) { throw new ApplicationException(); } if (!fileInfo.Exists) { throw new ApplicationException(); } ConfigXml cfg = null; XmlSerializer serializer = new XmlSerializer(typeof(ConfigXml)); using (TextReader reader = new StreamReader(fileInfo.FullName, System.Text.Encoding.Unicode)) { cfg = serializer.Deserialize(reader) as ConfigXml; reader.Close(); } if (cfg == null) { throw new ApplicationException(); } return(cfg); } catch { var cfg = new ConfigXml(); cfg.Save(fileInfo); return(cfg); } }
private void SaveSettings() { var config = new ConfigXml(); config.FirstNumber = (int)this.numFirst.Value; config.LastNumber = (int)this.numLast.Value; config.LastMission = string.IsNullOrWhiteSpace(this._LastFilename) ? "" : this._LastFilename; config.PositionX = this.Location.X; config.PositionY = this.Location.Y; config.Save(ConfigXml.Filename); }