0
我想將<compilation tempDirectory="MyPath"/>
添加到我的web服務的web.config中。tempDirectory編譯配置
是否可以指定相對路徑?或者它只能採取絕對路徑?
我想將<compilation tempDirectory="MyPath"/>
添加到我的web服務的web.config中。tempDirectory編譯配置
是否可以指定相對路徑?或者它只能採取絕對路徑?
指定編譯期間使用的臨時文件存放的目錄。
我認爲你最好的選擇是絕對路徑;
<compilation tempDirectory="Default Web Site/YourApp"/>
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"/>
我想爲tempDirectory是在相同的web服務...我嘗試TE mpDirectory =「Temp」...它抱怨它需要成爲一個絕對路徑。 :( – pdiddy 2010-04-27 20:04:04