Create a project and use Enterprise Library configuration to open web. config
Create configsection.
Rename to edit,
Create a new one at the edit node.
XML file storage provider
XML serializer Transformer
Set the filename of the XML file storage provider to the config file of the access information.
(Create a config file in the project and name it setting. config In the example)
Then save
Using System;
Using System. text;
Using System. xml. serialization;
Namespace Intlib
{
/**/ /// <Summary>
///Persen's summary.
/// </Summary>
Public Class Persen
{
Private String Name;
Private Int Age;
Private String Country;
Public Persen ()
{
//
//Todo: add the constructor logic here
//
}
Public String Name
{
Get {ReturnName ;}
Set {Name=Value ;}
}
Public Int Age
{
Get {ReturnAge ;}
Set {Age=Value ;}
}
Public String Country
{
Get {ReturnCountry ;}
Set {Country=Value ;}
}
}
}
One is write and the other is read,
Private Void Button#click ( Object Sender, system. eventargs E)
{
Persen PS = New Persen ();
PS. Name = This . Textbox1. text;
PS. Age = Int . Parse ( This . Textbox2.text );
PS. Country = This . Textbox3.text;
Configurationmanager. writeconfiguration ( " Edit " , PS );
}
Private Void Button2_click ( Object Sender, system. eventargs E)
{
Persen PS = Configurationmanager. getconfiguration ( " Edit " ) As Persen;
This . Textbox1. Text = PS. Name;
This . Textbox2.text = PS. Age. tostring ();
This . Textbox3.text = PS. Country;
}
The Enterprise Library will automatically serialize and deserialize objects...
Reading and writing data from config .....