根据虚拟目录获取物理路径
来源:互联网 发布:python socket框架 编辑:程序博客网 时间:2024/05/16 11:48
public string GetWebVirtualDirPath(string virtualDirectory)
{
string path= " ";
try
{
string rootPath = "IIS://localhost/W3SVC/1/Root ";
DirectoryEntry deRoot = new DirectoryEntry(rootPath);
DirectoryEntries entries = deRoot.Children;
DirectoryEntry descDir;
descDir = entries.Find(virtualDirectory,deRoot.SchemaClassName);
MessageBox.Show(virtualDirectory);
//if(descDir!=null)
// path=descDir.Properties[ "Path "][0].ToString();
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
return path;
}
调用如下:
string temp=GetWebVirtualDirPath( "eoffice ");
----------------------------------------------------
public static string GetWebVirtualDirPath(string virtualDirectory)
{
try
{
string iisServer = GetIISServerName();
string rootPath = "IIS:// " + iisServer + "/W3SVC/1/Root ";
DirectoryEntry deRoot = new DirectoryEntry(rootPath);
DirectoryEntries entries = deRoot.Children;
DirectoryEntry descDir;
descDir = entries.Find(virtualDirectory,deRoot.SchemaClassName);
if(descDir!=null)
return descDir.Properties[ "Path "][0].ToString();
else
return " ";
}
catch
{
return " ";
}
}
--------------------------------------------------------------------------
//返回的是指定虚拟目录的实际路径;
public string GetWebVirtualDirectoryPath(string iisName)
{
string iisPath = null;
try
{
DirectoryEntry _entry = new DirectoryEntry("IIS://localhost/W3SVC/1/Root");//此处现在只能读取到默认的80端口
DirectoryEntries _entries = _entry.Children;
foreach (DirectoryEntry _cen in _entries)
{
if (_cen.Name.ToLower() == iisName.ToLower())
{
DirectoryEntry root = new DirectoryEntry(_cen.Path);
iisPath = root.Properties["Path"].Value.ToString();
}
// string aa = _cen.Properties["Path"].Value.ToString();IIS://localhost/W3SVC/1/Root/bbb
}
}
catch (Exception ex)
{
throw ex;
}
return iisPath;
}
- 根据虚拟目录获取物理路径
- 如何获取虚拟目录对应的物理路径?
- 获取网站虚拟目录下的物理路径
- 获取IIS虚拟目录的物理路径
- 获取IIS虚拟目录的物理路径的方法
- C#获取本机IIS虚拟目录的物理路径
- js获取虚拟目录路径
- apache虚拟目录物理路径和端口修改
- asp.net取虚拟目录路径和物理路径
- android 根据非物理路径得到物理路径
- c#根据端口号获取IIS网站物理路径和网站名称
- IIS 创建虚拟目录 指定物理路径到其他机器
- 获取jsp的物理路径
- Struts2获取项目物理路径
- 获取java项目物理路径
- Javaweb 获取物理路径与网络路径
- C#根据路径获取文件名
- android 根据uri获取路径
- Java基础
- Red Hat Linux LVM配置关键步骤
- LINUX下USB1.1设备学习小记(4)_uhci(3)
- 告别数据线,QQ邮箱帮你隔空传图
- Jquery怎么获取select选中项 自定义属性的值
- 根据虚拟目录获取物理路径
- svn常用指令
- Eclipse
- mysql在已有无分区表增加分区,mysql5.5才有,可以是innodb_file_per_table关闭状态.
- LINUX下USB1.1设备学习小记(4)_uhci(4)
- DirectDraw结构及其功能说明
- HashMap和HashTable
- andriod的push实现
- 程序员求职之道(《程序员面试笔试宝典》)之面试笔试技巧?