Reputation: 10247
I've got this code that saves a test file in what I assumed would be my project's bin folder:
XDocument doc = XDocument.Parse(stringifiedXML);
doc.Save("testXMLFile.xml");
...but it actually ended up in C:\Program Files (x86)\IIS Express
Yes, IIS Express is hosting this Web API app yet, when the app is run from Visual Studio, I would expect the file to be saved to the project's bin folder. Why this?
I can designate just where I want the file to be saved like so:
// In PlatypusGlobals.cs
public static string appDataFolder = HttpContext.Current.Server.MapPath("~/App_Data/");
doc.Save(string.Format("{0}testXMLFile2.xml", PlatypusGlobals.appDataFolder));
...but would still prefer a "raw save" to go to the bin directory. Is this configurable, or do I just have to live with files being saved to the IIS Express folder?
Upvotes: 2
Views: 2012
Reputation: 3302
I think you're misunderstanding how the program is executed. It is never executed "from" Visual Studio. It is executed from IIS Express, and Visual Studio attaches to it.
Because this program is executing under IIS Express, the program's executable path is under the IIS Express directory. This will be different if you use a local install of full IIS, since it creates a virtual directory that runs your dlls directly from the bin folder.
Upvotes: 5