Some parameters need to be saved to files during system creation,
The format is as follows:
Username = Tom; </P> <p> sex = male; </P> <p> age = 50; </P> <p>
It is troublesome to get the username value. I wrote a method myself.
Put these values in dictionary, and all keys are in lowercase.
/// <Summary>
/// Parse the configuration file data
/// </Summary>
/// <Param name = "data"> data read from a file or memory </param>
/// <Returns> </returns>
Private Static dictionary <string, string> analyseconfig (byte [] data)
{
String allstr = new system. Text. asciiencoding (). getstring (data );
// Allstr = allstr. Replace ('/N ','');
Allstr = allstr. Replace ('/R ','');
String [] Config = allstr. Split (New char [] {'/N ',';'});
String [] KV = {"",""};
Dictionary <string, string> dconfig = new dictionary <string, string> ();
For (INT I = 0, Ln = config. length; I <ln; I ++)
{
If (! String. isnullorempty (config [I])
{
KV = config [I]. Split (New char [] {'= '});
Try
{
Dconfig. Add (Kv [0]. tolower (), Kv [1]);
}
Catch (system. indexoutofrangeexception ex)
{
}
}
}
Return dconfig;
}