C# 临时目录编译配置
我想将C# 临时目录编译配置,c#,.net,web-services,C#,.net,Web Services,我想将添加到我的web服务的web.config中 是否可以指定相对路径?或者它只能采取绝对路径?从 指定编译期间用于临时文件存储的目录 我认为你最好的选择是绝对路径;但是,你可以试试相对的方法,比如: <compilation tempDirectory="Default Web Site/YourApp"/> 来自 指定编译期间用于临时文件存储的目录 我认为你最好的选择是绝对路径;但是,你可以试试相对的方法,比如: <compilation tempDirectory=
添加到我的web服务的web.config中
是否可以指定相对路径?或者它只能采取绝对路径?从
指定编译期间用于临时文件存储的目录
我认为你最好的选择是绝对路径;但是,你可以试试相对的方法,比如:
<compilation tempDirectory="Default Web Site/YourApp"/>
来自
指定编译期间用于临时文件存储的目录
我认为你最好的选择是绝对路径;但是,你可以试试相对的方法,比如:
<compilation tempDirectory="Default Web Site/YourApp"/>
临时目录的处理如下:
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);
}
其中,如果(路径[0]为“\”或“/”)或(路径[1]为“:”),则IsPathRooted返回true
要设置相对路径,请执行以下操作:
<compilation tempDirectory="/Default Web Site/YourApp"/>
临时目录的处理如下:
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);
}
其中,如果(路径[0]为“\”或“/”)或(路径[1]为“:”),则IsPathRooted返回true
要设置相对路径,请执行以下操作:
<compilation tempDirectory="/Default Web Site/YourApp"/>
无法指定相对路径,因为错误消息也明确指出。无法指定相对路径,因为错误消息也明确指出。转到webconfig文件,仅删除路径
这通常会导致文件从一个域移动到另一个域。转到webconfig文件,仅删除路径
这通常会导致文件从一个域移动到另一个域。我希望tempDirectory与webservice位于同一个域中。。。我试过tempDirectory=“Temp”。。。它抱怨说它需要成为一条绝对的道路(我想让tempDirectory与webservice处于相同的位置……我尝试了tempDirectory=“Temp”……它抱怨它需要一个绝对路径。:(据我从测试中看到的(VS2017)通过阅读代码,这样的路径将被解释为根路径,这意味着
/Default Web Site/YourApp
文件夹将最终位于驱动器的根目录中。似乎没有任何方法可以指定相对文件夹。据我在测试中看到的(VS2017)通过阅读代码,这样的路径将被解释为根路径,这意味着/Default Web Site/YourApp
文件夹将最终位于驱动器的根目录中。似乎没有任何方法可以指定相对文件夹。您是否解决了相对路径问题?无法设置相对路径似乎很荒谬。这是怎么回事当站点不在您的前提下,ISP没有告诉您托管站点的绝对路径时,e应该怎么做?您是否解决了相对路径问题?无法设置相对路径似乎很荒谬。当站点不在您的前提下,ISP没有告诉您托管站点的绝对路径时,应该怎么做?