How do I read get the full path of a static XML file I added to my C# WCF project?
A:
When you added it, the file was copied into the directory where your csproj file is.
Steven Sudit
2009-12-15 19:10:45
+1
A:
What is a "static XML file" for you?
You can use Assembly.GetEntryAssembly().Location in combination with Path.Combine if you want to access a file in the same directoy as your executable (or in any subdirectory).
Or did you compile it as a resource? Then, you can't access it via the file system.
winSharp93
2009-12-15 19:13:03
This answer is as correct as mine: obviously, none of us can be sure what the questioner actually meant.
Steven Sudit
2009-12-15 19:24:08
A:
If you're at development stage, you probably just hit F5 and your program runs.
It run from bin\debug
folder, so you need to go up two levels and you'll be at your project root directory. If you created a folder to keep your static files, you'll need to do:
string myStaticXmlFilePath = @"..\..\StaticFiles\MyStaticXmlFile.xml";
Rubens Farias
2009-12-15 19:21:31
I would imagine that the file is set to be copied to the output directory.
Steven Sudit
2009-12-15 19:23:33
True enough. However, without this, there's no guarantee that the file will be available after installation.
Steven Sudit
2009-12-16 16:33:06