2010-04-27 140 views
0

我想将<compilation tempDirectory="MyPath"/>添加到我的web服务的web.config中。tempDirectory编译配置

是否可以指定相对路径?或者它只能采取绝对路径?

回答

0

tempDirectory

指定编译期间使用的临时文件存放的目录。

我认为你最好的选择是绝对路径;

<compilation tempDirectory="Default Web Site/YourApp"/> 
+0

我想为tempDirectory是在相同的web服务...我尝试TE mpDirectory =“Temp”...它抱怨它需要成为一个绝对路径。 :( – pdiddy 2010-04-27 20:04:04

0

temp目录的处理过程如下:但是,可以象尝试相对

if ((compilationSection != null) && !string.IsNullOrEmpty(compilationSection.TempDirectory)) 
{ 
    path = compilationSection.TempDirectory; 
    compilationSection.GetTempDirectoryErrorInfo(out tempDirAttribName, out configFileName, out configLineNumber); 
} 
if (path != null) 
{ 
    path = path.Trim(); 
    if (!Path.IsPathRooted(path)) 
    { 
     path = null; 
    } 
    else 
    { 
     try 
     { 
      path = new DirectoryInfo(path).FullName; 
     } 
     catch 
     { 
      path = null; 
     } 
    } 
    if (path == null) 
    { 
     throw new ConfigurationErrorsException(SR.GetString("Invalid_temp_directory", new object[] { tempDirAttribName }), configFileName, configLineNumber); 
    } 

其中IsPathRooted返回真,如果(路径[0]为 '\' 或 '/')或(路径[1]是“:”)

设置相对路径:

<compilation tempDirectory="/Default Web Site/YourApp"/>