private void btnAccept_Click(object sender, RoutedEventArgs e) { Attributs attr = new Attributs(); attr.Addr = tbAddress.Text; attr.Name = tbYour_name.Text; attr.SMTP = tbSMTP.Text; attr.Port = tbPort.Text; attr.Password = tbPassword.Text; attr.Sign = tbSign.Text; string filename = "options.xml"; XmlSerializer ser = new XmlSerializer(typeof(Attributs), filename); Stream f = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write); ser.Serialize(f, attr); f.Close(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Attributs attr = new Attributs(); string filename = "options.xml"; try { XmlSerializer ser = new XmlSerializer(typeof(Attributs), filename); Stream f = new FileStream(filename, FileMode.Open, FileAccess.Read); attr = (Attributs)ser.Deserialize(f); tbAddress.Text = attr.Addr; tbYour_name.Text = attr.Name; tbSMTP.Text = attr.SMTP; tbPort.Text = attr.Port; tbPassword.Text = attr.Password; tbFullSign.Text = attr.Sign + ' ' + attr.Name; tbSign.Text = attr.Sign; f.Close(); } finally { }; }