I have a file called settings.xml located at:
c:\solution1\solution1\data\settings.xml
Right now, I am doing:
XDocument doc = XDocument.Load(@"c:\solution1\solution1\settings.xml");
I can’t figure how to do it with a relative path.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you mean relative to your executable, you can use
Note the frequently suggested
will get the path where the assembly is currently located, which can be different e.g. if a shadow copy is being executed.
You can use
to get the executable’s directory.
If you want to find a file that is in a data directory under your install location, you could do
Note that under Windows Vista and later, you will not have write access by default to a directory located under your install directory.