C#如何找到WCF IIS部署/虚拟目录在运行时更改日志文件的名字吗? [英] C# How to find WCF IIS deployment/virtual directory at runtime to change name of log file?

查看:356
本文介绍了C#如何找到WCF IIS部署/虚拟目录在运行时更改日志文件的名字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变基于它部署到IIS虚拟目录名的C#WCF日志文件的名称。



我试图用Directory.GetCurrentDirectory()调用,但它返回目录c:\windows\system32\inetsrv无论是哪个虚拟目录的WCF应用程序是部署到..



所以,我应该寻找到VirtualDirectory类?如何找到当前虚拟目录?



谢谢!


解决方案

你试试这个:

 路径字符串= HostingEnvironment.MapPath(〜); 


I am trying to change the name of a c# WCF logfile based on the name of the IIS Virtual directory it is deployed to.

I tried to use the Directory.GetCurrentDirectory() call but it returns the directory c:\windows\system32\inetsrv regardless which virtual directory the WCF apps was deployed to..

So should I be looking into the VirtualDirectory Class ?? Any sample code on how to find the current Virtual Directory ?

Thanks !

解决方案

Did you try this:

string path = HostingEnvironment.MapPath("~"); 

这篇关于C#如何找到WCF IIS部署/虚拟目录在运行时更改日志文件的名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆