One easy way to do this is to create the .NET classes in which you put the data, and then use the XmlSerializer to serialize the data to a file, and then deserialize it back to the class instance and re-fill the form.
, . , . . , : / , .
public class CustomerData
{
public string FirstName;
public string LastName;
}
, XML, .
CustomerData customer = new CustomerData();
customer.FirstName = txtFirstName.Text;
customer.LastName = txtLastName.Text;
XmlSerializer xs = new XmlSerializer(typeof(CustomerData));
using (FileStream fs = new FileStream("Data.xml", FileMode.Create))
{
xs.Serialize(fs, customer);
}
:
CustomerData customer;
XmlSerializer xs = new XmlSerializer(typeof(CustomerData));
using (FileStream fs = new FileStream("Data.xml", FileMode.Open))
{
customer = xs.Deserialize(fs) as CustomerData;
}
if (customer != null)
{
txtFirstName.Text = customer.FirstName;
txtLastName.Text = customer.LastName;
}