I'm trying to find a file in a settings folder in my application. I have a xml file there. When I run the following code:
XDocument xDoc = XDocument.Load(@"..\settings\Settings.xml");
By default, the build results in Visual Studio are saved in a folder like
bin\Debug. Since you use a relative path that jumps one folder higher, you get
yourProjectFolder\bin\settings\Settings.xml. That file doesn't exist, since it's presumably in the project folder, not the bin folder.
The typical way to deal with this is to make sure the files that are supposed to be a part of the content actually have Build Action set to Content.
Using a rooted path definitely works - most likely, you made a mistake somewhere; either the path isn't rooted at all, or you're doing something like interpreting the path as an URI rather than a file path.
XDocument.Load takes a URI, not a file path - the proper way to reference an absolute path on the filesystem would be