来自特殊文件夹的空字符串(loadUserProfile为“true”)

本文关键字:loadUserProfile true 字符串 文件夹 | 更新日期: 2023-09-27 18:12:05

我需要使用一些文件夹的临时文件。我试着用

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

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

所以我试着用:

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

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

我检查了loadUserProfile是"true"

还有其他建议吗?

来自特殊文件夹的空字符串(loadUserProfile为“true”)

一些特殊路径是特定于登录用户的,特殊用户帐户(如appool)可能没有这样的文件夹。我建议使用GetTempPath (http://msdn.microsoft.com/en-us/library/system.io.path.gettemppath.aspx)或在您的网站中创建一个目录,以达到这样的目的(但设置了安全设置,以便网站用户无法浏览到它)。