对虚拟目录的操作(转)
private bool IsExitesVirtualDir(string virtualdirname)
{
bool exited =false;
DirectoryEntry _entry = new DirectoryEntry("IIS://localhost/W3SVC/1/Root");
DirectoryEntries _entries = _entry.Children;
foreach(DirectoryEntry _cen in _entries)
{
if(_cen.Name == virtualdirname)
exited = true;
}
return exited;
}
其中virtualdirpath指要建立的虚拟目录名称;
二、新增虚拟目录
private void CreateVirtualDir(string virtualdirname,string logicDir)
{
if(IsExitesVirtualDir(virtualdirname))
DeleteVirtualDir(virtualdirname);
DirectoryEntry _rootEntry ;
_rootEntry = new DirectoryEntry("IIS://localhost/W3SVC/1/root");
DirectoryEntry _newVirDir;
_newVirDir = _rootEntry .Children.Add(virtualdirpath,"IIsWebVirtualDir");
_newVirDir.Invoke("AppCreate",true);
_newVirDir.CommitChanges();
_rootEntry .CommitChanges();
_newVirDir.Properties["AnonymousPasswordSync"][0] = true;
_newVirDir.Properties["Path"][0] = logicDir + @"virtualdirentry\virtualname\";
_newVirDir.CommitChanges();
}
_newVirDir.Properties["Path"][0] 的值为虚拟目录对应的物理地址;
三、更新虚拟目录
public void Update(string virtualdirname)
{
//判断需要更改的虚拟目录是否存在
if(_IsExitesVirtualDir(virtualdirname))
{
DirectoryEntry _rootEntry ;
_rootEntry = new DirectoryEntry("IIS://localhost/W3SVC/1/root");
DirectoryEntry ode = _rootEntry.Children.Find(virtualdirname,"IIsWebVirtualDir");
UpdateDirInfo(ode);
}
}
private void UpdateDirInfo(DirectoryEntry de)
{
de.Properties["AnonymousUserName"][0] = AnonymousUserName;
de.Properties["AnonymousUserPass"][0] = AnonymousUserPass;
de.Properties["AccessRead"][0] = boolen;
de.Properties["AccessExecute"][0] = boolen;
de.Properties["AccessWrite"][0] = boolen;
de.Properties["AuthBasic"][0] = boolen;
de.Properties["AuthNTLM"][0] = boolen;
de.Properties["ContentIndexed"][0] = boolen;
de.Properties["EnableDefaultDoc"][0] = boolen;
de.Properties["EnableDirBrowsing"][0] = boolen;
de.Properties["AccessSSL"][0] = boolen;
de.Properties["AccessScript"][0] = boolen;
de.Properties["DefaultDoc"][0] = DefaultDoc;
de.Properties["Path"][0] = Path;
de.CommitChanges();
}
四、删除虚拟目录
private void DeleteVirtualDir(string virtualdirname)
{
DirectoryEntry _rootEntry ;
_rootEntry = new DirectoryEntry("IIS://localhost/W3SVC/1/root");
object[] paras = new object[2];
paras[0] = "IIsVirtualDir";
paras[1] = virtualdirname;
_rootEntry .Invoke("Delete",paras);
_rootEntry .CommitChanges();
}
转载于:https://www.cnblogs.com/wpf123/archive/2010/01/21/2347372.html
对虚拟目录的操作(转)相关推荐
- .net对虚拟目录的操作
一.查看虚拟目录是否存在 private bool IsExitesVirtualDir(string virtualdirname) { bool exited =false; ...
- c# 操作服务器虚拟目录,C# 操作IIS服务器Demo
原标题:C# 操作IIS服务器Demo using System; using System.Collections; using System.Collections.Generic; using ...
- vbs脚本在服务器上虚拟按键,iisvdir.vbs iis虚拟目录管理脚本使用介绍
IIS管理器也是通过调用iisvdir.vbs来实现虚拟目录的创建和删除的.我们可以通过命令行的方式来执行iisvdir.vbs脚本 1)创建虚拟目录: cscript c:\windows\syst ...
- xp创建虚拟服务器,Xp系统怎么创建虚拟目录?Xp系统创建虚拟目录的方法
Xp系统怎么创建虚拟目录?xp系统是一款非常经典的windows系统,其一直深受着广大用户们的喜爱.虽然目前微软不在支持xp系统了但是使用还是有部分用户选择使用xp系统.下面小编就给大家带来Xp系统创 ...
- IIS7中的站点、应用程序和虚拟目录详细介绍
这里说的不是如何解决路径重写或者如何配置的问题,而是阐述一下站点(site),应用程序(application)和虚拟目录(virtual directory)概念与作用,已及这三个东西在IIS6与I ...
- Apache 下更改 DocumentRoot 和新建虚拟目录
Apache 安装后,默认的 DocumentRoot 是安装目录下的 htdocs 目录,编程时有很多不便,如需更改,打开安装目录 conf 子目录下的 httpd.conf 文件,修改 Docum ...
- Asp.net网站的ClickOnce自动部署(2)-虚拟目录的配置
第一步先讲虚拟目录的配置,虚拟目录的配置简单来说就是创建虚拟目录.用手工的方式实现非常简单,直接设定"Web sharing"就可以了,让我们看看怎么通过编程的方式实现,本文将介绍 ...
- windows server 2012 FTP 服务器 / 虚拟目录
@time 2019-07-05 @author Ruo_Xiao 1.作用 虚拟目录就是将其他目录以映射的方式虚拟到该 FTP 服务器的主目录下.这样,一个 FTP 服务器的主目录实质上就可以包括很 ...
- WEB程序打包详解:(连接SQL2005数据库,修改配置文件,建立虚拟目录)
做了一个web的打包程序,和大家分享一下. 第一步:新建--文件--项目,弹出对话框 如图,选择安装和部署--安装项目 这里要解释一下了,一般来说,制作web安装程序选择web安装项目,而我没有选择w ...
最新文章
- JS中的call()方法和apply()方法用法总结
- 可伸缩性架构常用技术——之数据切分
- orangepi找不到GPIO的解决方法
- Developer Express控件组合中的GridControl控件,如何自动显示每一行的序号
- RabbitMQ+PHP 教程六(RPC)
- OpenGL ES入门
- UGUI- 单列列表(VerticalLayoutGroup)
- 官网消息【iPlayer外挂字幕】功能开发中!有图
- 委托的定义,与简单使用
- 顺序栈的基本操作(超详细)
- 8086微型计算机原理答案,8086微型计算机原理与应用(吴宁)习题参考答案(第一章)...
- linux操作系统第三版课后题答案,linux操作系统( 课后习题答案).doc
- LSD-SLAM运行过程及报错 “what(): Duration is out of dual 32-bit range“
- oracle web创建表空间,oracle 创造表空间常用
- 静态网页与动态网页的差异
- mysql 修改分区名_修改数据库分区表分区名和所属表空间,限于Oracle10g
- 安装目录里无法找到计算机,Win7系统下programdata文件夹找不到怎么办?
- php 获取网络图片合成,PHP使用imagick扩展实现合并图像的方法
- unittest学习(一)
- 用DriverBackUp备份了文件 装好系统后怎么把备份的驱动文件还原
热门文章
- Redis工作笔记-持久化
- Spring Boot笔记-jQuery使用load进行异步调用
- Spring Boot静态资源映射规则
- 数仓主题表怎么设计_陶瓷企业展厅设计主题风格怎么确定?
- java 点对点_[java] java消息服务 (二) 点对点模型P2P
- java if和else if的区别_关于C语言中if,elseif和else的区别在哪里
- FrameLayout 测量过程
- python 判断数字连续_关于python:检测列表中的连续整数
- proteus如何添加stm32_新手入门轻松掌握 STM32 串口应用
- 微信小程序上传大于4m_微信定制小程序开发