File Path in XML

Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2007
Posts: 78
Reputation: shers is an unknown quantity at this point 
Solved Threads: 0
shers shers is offline Offline
Junior Poster in Training

File Path in XML

 
0
  #1
Nov 25th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: File Path in XML

 
0
  #2
Nov 25th, 2008
here's a simple example, probably overkill for what you need

http://www.c-sharpcorner.com/UploadF...tMellli21.aspx
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 78
Reputation: shers is an unknown quantity at this point 
Solved Threads: 0
shers shers is offline Offline
Junior Poster in Training

Re: File Path in XML

 
0
  #3
Jan 11th, 2009
string path = Properties.Settings.Default.ParentPath;
DirectoryInfo di =new DirectoryInfo(path);

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

Thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: File Path in XML

 
0
  #4
Jan 11th, 2009
Then its probably true.
Whats in your path?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 78
Reputation: shers is an unknown quantity at this point 
Solved Threads: 0
shers shers is offline Offline
Junior Poster in Training

Re: File Path in XML

 
0
  #5
Jan 11th, 2009
"C:\Test"
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: File Path in XML

 
0
  #6
Jan 11th, 2009
is that the debug value, or the displayed if you print it out value?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 97
Reputation: VIeditorlover is an unknown quantity at this point 
Solved Threads: 5
VIeditorlover's Avatar
VIeditorlover VIeditorlover is offline Offline
Junior Poster in Training

Re: File Path in XML

 
0
  #7
Jan 12th, 2009
Originally Posted by shers View Post
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
  1. using System.Xml;
  2. ...
  3. XmlDocument xd = new XmlDocument();
  4. xd.Load ("myconfig.xml");
  5. ...
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 78
Reputation: shers is an unknown quantity at this point 
Solved Threads: 0
shers shers is offline Offline
Junior Poster in Training

Re: File Path in XML

 
0
  #8
Jan 12th, 2009
Originally Posted by LizR View Post
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: File Path in XML

 
0
  #9
Jan 12th, 2009
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
Last edited by LizR; Jan 12th, 2009 at 8:47 am.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 78
Reputation: shers is an unknown quantity at this point 
Solved Threads: 0
shers shers is offline Offline
Junior Poster in Training

Re: File Path in XML

 
0
  #10
Jan 12th, 2009
WOW! It worked. I removed the quotes. Thanks a lot LizR. Why didn't I try removing the quotes earlier?
Last edited by shers; Jan 12th, 2009 at 9:03 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC