【问题标题】:empty string from special folder (loadUserProfile is "true")特殊文件夹中的空字符串(loadUserProfile 为“true”)
【发布时间】:2013-05-05 07:13:57
【问题描述】:

我需要为临时文件使用一些文件夹。 我尝试使用

    string directoryPath = HttpContext.Current.Server.MapPath("~/tempFiles");

但是当我将它发布到 IIS 时,我遇到了权限问题。

所以我尝试使用:

    string directoryPath = Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);

当我从 VS2012 运行我的 Web 应用程序时,它工作正常,但是当我将它发布到 iis 并在那里运行时,我得到一个空字符串。

我检查了 loadUserProfile 是“真”

还有什么建议吗?

【问题讨论】:

  • 您的 IIS 是否在完全信任的环境中运行?
  • @TamarG:尝试将 ApplicationPoolIdentity 设置为 LocalSystem

标签: c# iis-7 directory special-folders


【解决方案1】:

有些特殊路径是登录用户特有的,apppool等特殊用户账户可能没有这样的文件夹。我建议要么使用 GetTempPath (http://msdn.microsoft.com/en-us/library/system.io.path.gettemppath.aspx),要么为此目的在您的网站内创建一个目录(但要设置安全性,以便网站用户无法浏览它)。

【讨论】:

    猜你喜欢
    • 2018-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多