.ini file

Leeus

Regular
Joined
Dec 23, 2002
Messages
50
I read somewhere that vb.net wanted to do away with ini files and store variables in a similar fashion somewhere else.

The reason I ask is that I want to create a settings file but hoped that .net would have a global variables file that would stay intact even after code closed down!
 
The short answer is, use XML files. You can either have all your project settings as a class, and use XML serialization to persist it, or use the XmlTextWriter and XmlTextReader classes to read and write to a file manually.
 
Not that I know of. The MSDN help is actually quite good when it comes to the XML namespaces, and there are some good samples in the Framework SDK which demonstrate various techniques.
 
Great piece of code PhilBayley showed me that uses data sets:

C#:
DataSet AppConfig = new DataSet("MyApp");
			
JobConfig.Tables.Add("Files");
JobConfig.Tables["Directories"].Columns.Add("File Descriptions");
JobConfig.Tables["Directories"].Columns.Add("Paths");

DataRow dr = JobConfig.Tables["Directories"].NewRow();
dr[0] = "File1";
dr[1] = "c:\\temp\\1.txt";

JobConfig.Tables["Directories"].Rows.Add(dr);
JobConfig.WriteXml("c:\\temp.xml", XmlWriteMode.WriteSchema);

Tada, nice tabular structure - easy to read in and loop over.
 
Blummin eck!

I thought I had seen that before.

Good job I dont make money from writing that stuff!

Oops hang on - I do make money doing that.

Oi!
 
Back
Top