简体   繁体   English

为什么默认情况下将此文件保存到IIS Express文件夹?

[英]Why is this file saved by default to the IIS Express folder?

I've got this code that saves a test file in what I assumed would be my project's bin folder: 我有这段代码将测试文件保存在我认为是项目的bin文件夹中的代码中:

XDocument doc = XDocument.Parse(stringifiedXML);
doc.Save("testXMLFile.xml"); 

...but it actually ended up in C:\\Program Files (x86)\\IIS Express ...但是它实际上以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. 是的,IIS Express仍在托管此Web API应用程序,当从Visual Studio运行该应用程序时,我希望将文件保存到项目的bin文件夹中。 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. ...但是仍然希望“原始保存”进入bin目录。 Is this configurable, or do I just have to live with files being saved to the IIS Express folder? 这是可配置的,还是只需要保存文件到IIS Express文件夹中即可?

I think you're misunderstanding how the program is executed. 我认为您误会了程序的执行方式。 It is never executed "from" Visual Studio. 永远不会从“ Visual Studio”执行它。 It is executed from IIS Express, and Visual Studio attaches to it. 它是从IIS Express执行的,Visual Studio会附加到它。

Because this program is executing under IIS Express, the program's executable path is under the IIS Express directory. 因为此程序在IIS Express下执行,所以该程序的可执行路径在IIS Express目录下。 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. 如果您使用本地安装完整IIS,则情况会有所不同,因为它会创建一个虚拟目录,该目录直接从bin文件夹运行您的dll。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM