GetFolderPath(SpecialFolder.ApplicationData)返回空字符串 [英] GetFolderPath(SpecialFolder.ApplicationData) returns empty string

查看:379
本文介绍了GetFolderPath(SpecialFolder.ApplicationData)返回空字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到很多这样的老问题,但不是我的情况。

I saw many old questions like this but it is not my case.

Asp.net应用程序在AppPool中运行(iis在win10中),带有'load user profile '启用。

Asp.net application is running in AppPool (iis in win10) with 'load user profile' enabled.

然而,Environment.GetFolderPath(ApplicationData或LocalApplicationData)返回一个空字符串。 CommonApplicationData返回正确的文件夹。

And nevertheless Environment.GetFolderPath(ApplicationData or LocalApplicationData) returns an empty string. CommonApplicationData returns correct folder.

我确保磁盘上存在{user} \ AppData。

I ensure that {user}\AppData is exist on disk.

所以,问:我怎样才能得到AppData的空字符串?

So, question: how can I get not empty string for AppData?

推荐答案

在IIS中启用'loadUserProfile'选项是不够的!

It is not enough to enable 'loadUserProfile' option in IIS!

你必须启用另一个一种选择。这是'setProfileEnvironment'。我没有找到IIS UI来更改它。

You have to enable another one option. This is 'setProfileEnvironment'. I didn't find IIS UI to change it.

%windir%\system32 \inetsrv\config \ applicationHost中打开文件.config 并添加或更改应用程序池的属性。

Open file in %windir%\system32\inetsrv\config\applicationHost.config and add or change attributes for your application pool.

<configuration>
    <system.applicationHost>
        <applicationPools>
            <add name="YourPool" >
                <processModel  
                 loadUserProfile="true" 
                 setProfileEnvironment="true"/>

之后你可以得到ApplicationData或LocalApplicationData路径!

And after that you can get ApplicationData or LocalApplicationData path!

这篇关于GetFolderPath(SpecialFolder.ApplicationData)返回空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆