Click to See Complete Forum and Search --> : Properties File


dunezone
January 18th, 2010, 11:59 AM
Working on creating a program that dynamically changes based on a properties file. I already did this in my first of the program but I am looking for a better method to read a properties file, sort out the configuration, etc, etc.

My current method goes like this


string[] configProp = File.ReadAllLines(@"properties.file");
string test1 = configProp[0];
string test2 = configProp[1];
string test 4 = test1.Remove(0, 11);
string test 5 = test2.Remove(0, 16);


I read the file into a string array. Then reassign each array to another string, and then proceed to chop it up. This works but its a lot of work, I cant change the properties file layout without moving and rearranging code. Also, verifying no mistakes are in the properties file is something I don't even know how to implement.

Does anyone have any examples of loading a properties file or config file and doing some basic validation?

memeloo
January 18th, 2010, 12:10 PM
have you tried it with XML?

dunezone
January 18th, 2010, 12:17 PM
Now I feel like an idiot. My last program loaded XML but I did nothing with it really. I think that would be the best solution for this.