title: IIS 7.5 application pool uses wrong %APPDATA% for custom user as identity
body: <p>I want my MVC3 web application to access %APPDATA% (e.g. <code>C:\Users\MyUsername\AppData\Roaming</code> on Windows 7) because I store configuration files there. Therefore I created an application pool in IIS with the identity of the user "MyUsername", created that user's profile by logging in with the account, and turned on the option "Load User Profile" (was true by default anyway). Impersonation is turned off.</p>
  
  <p>Now I have the problem that %APPDATA% (in C#):</p>
  
  <pre><code>appdataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
  </code></pre>
  
  <p>resolves to <code>c:\windows\system32\inetsrv</code> instead of <code>C:\Users\MyUsername\AppData\Roaming</code>.</p>
  
  <p><strong>UPDATE:</strong> More exactly, the above C# code returns an empty string, so that <code>Path.GetFullPath(Path.Combine(appdataDir, "MyAppName"))</code> prepends the current path to my application name, resulting in <code>c:\windows\system32\inetsrv\MyAppName</code>.</p>
  
  <p><strong>I know I made this work before with the same web application on a Windows Server 2008 R2, and now I'm getting this problem with the same major version 7.5 of IIS on my Windows 7.</strong><br>
  I used the same procedure as before: Created a new user, logged in as that user to create the profile and APPDATA directories, then added the application pool with this identity and finally added the web application to this pool.</p>
  
  <p>Any ideas?</p>