用.NET在IIS中创建虚拟目录

这篇博客介绍了如何利用.NET的DirectoryEntry类在IIS上创建虚拟目录。详细步骤包括设置DirectoryEntry属性,如路径、权限、日志记录、默认文档和应用程序配置。代码示例展示了创建虚拟目录的具体实现,包括设置各种属性和调用AppCreate方法。
摘要由CSDN通过智能技术生成
 

使用.NET的目录服务就可以访问IIS的设置,添加虚拟目录其实就是创建一个DirectoryEntry
复杂的在于DirectoryEntry的属性,其实就是虚拟目的一些配置,比如,权限,是否要log,应用程序名等
Properties非常多,而且文档不太好找
详细可以参考MSDN以下内容
help://MS.MSDNQTR.2004JUL.1033/iissdk/iis/configuring_properties_in_the_iis_user_interface.htm

代码示例:

   const String constIISWebSiteRoot = "IIS://localhost/W3SVC/1/ROOT";

   DirectoryEntry root = new DirectoryEntry(constIISWebSiteRoot);
   DirectoryEntry entry = new DirectoryEntry(constIISWebSiteRoot + "/" + virtualDirName);

   DirectoryEntry tbEntry = root.Children.Add(virtualDirName, "IIsWebVirtualDir");

   //must be end with a '/'
   tbEntry.Properties["Path"][0] = virtualDirPath;
   tbEntry.Invoke("AppCreate",true);
   tbEntry.Properties["AccessRead"][0] = true;
   tbEntry.Properties["ContentIndexed"][0] = false;
   tbEntry.Properties["DefaultDoc"][0] = "index.asp";
   tbEntry.Properties["AppFriendlyName"][0] = virtualDirName;
   tbEntry.Properties["AppIsolated"][0] = 2;
   tbEntry.Properties["AccessScript"][0] = true;   <

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值