Get DefaultAppPool AppData folder from web application

I have a web application that runs with a DefaultAppPool account. I want to write some files to the DefaultAppPool AppData folder (or any other folder 100% accessible from the account that my application launches)

I 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.

How can I get the AppData path for DefaultAppPool?

EDIT: This code runs in the model

+6
source share
2 answers

I do it like this:

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

I did it like this:

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

All Articles