Hi all,

I'm creating a progam in C# that reads a file location at start up and displays the parent folders in a combo box. This file location may change in future. So I intend to keep this in an xml file and allow the user to change it when needed. But how do I go about it? I have not done any coding with xml yet. So, please help.

Thanks

string path = Properties.Settings.Default.ParentPath;
DirectoryInfo di =new DirectoryInfo(path);

Gives an error that says, 'Illegal characters in path.'

Thanks

Then its probably true.
Whats in your path?

is that the debug value, or the displayed if you print it out value?

Hi all,

I'm creating a progam in C# that reads a file location at start up and displays the parent folders in a combo box. This file location may change in future. So I intend to keep this in an xml file and allow the user to change it when needed. But how do I go about it? I have not done any coding with xml yet. So, please help.

Thanks

using System.Xml;
...
XmlDocument xd = new XmlDocument();
xd.Load ("myconfig.xml");
...

is that the debug value, or the displayed if you print it out value?

When I wrote "C:\\Test" in the settings, the path returned in

DirectoryInfo di =new DirectoryInfo(path);

is "\"C:\\\\Test\" and when it's @"C:\Test", it returns "@\"C:\\Test\""

The error is 'Illegal characters in path.'

Thanks

Without seeing the code for that the fact it says "@\"C:\\Test\"" for example, implies its encoding the whole @"C:\Test" as the filename, which is correct. " marks etc arent a valid file name, while c:\test can be.

If you're entering the path in a text box, dont enter the @ or " marks

WOW! It worked. I removed the quotes. Thanks a lot LizR. Why didn't I try removing the quotes earlier?

Dont ask me :)
Please make sure you mark it as closed