Home > Uncategorized > Configuration files for windows forms

Configuration files for windows forms

I often found that it was time consuming, when putting together a "Throw-away" application, that so much UI plumbing was required – with check boxes, text boxes, listboxes etc. were required to allow some sort of user configurability. Of course, a UI is required for a public App., but for personal use, I thought it might be handier to use an XML file, slapped into the same Bin folder as the executing assembley.

So for instance, with an XML file like


I put this function in to rhe main function

public void readConfigXml()


string path = System.IO.Path.GetDirectoryName(

System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );

path = path.Substring(6);

FileStream xmlFile =

new FileStream(path + "\config.xml",FileMode.Open);

string xmlContent = new StreamReader(xmlFile).ReadToEnd();


XmlDocument doc = new XmlDocument();

doc = new XmlDocument();


XmlElement root = doc.DocumentElement;

websites = root.ChildNodes[0].ChildNodes;

files = root.ChildNodes[1].ChildNodes;









Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: