简体   繁体   English

从Web应用程序获取DefaultAppPool AppData文件夹

[英]Get DefaultAppPool AppData folder from the web application

I have a web application which is running from DefaultAppPool account. 我有一个从DefaultAppPool帐户运行的Web应用程序。 I want to write some files into the DefaultAppPool's AppData folder (or any other folder, which is 100% accessible from the account my application is running) 我想将一些文件写入DefaultAppPool的AppData文件夹(或任何其他文件夹,可以从我的应用程序运行的帐户100%访问)

I've tried 我试过了

Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData)

but for some reason, it returns an empty string. 但由于某种原因,它返回一个空字符串。

Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile)

returns C:\\\\Users\\DefaultAppPool as expected. 按预期返回C:\\\\Users\\DefaultAppPool

How can I get the AppData path for DefaultAppPool? 如何获取DefaultAppPool的AppData路径?

EDIT: This code is executed in the Model 编辑:此代码在模型中执行

我是这样做的:

var path = string.Format("{0}\\{1}", Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile), "AppData")

我是这样做的:

string apPath = Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, "App_Data");

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

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