一。IIS属性集VirtualDirectory类 using System; using System.DirectoryServices; // 添加DirectorysServices引用! /// <summary> /// 自定义基于DirectoryServices的IIS虚拟目录管理服务, /// 支持创建、更新、删除Web和Ftp虚拟目录。 /// </summary> namespace VirtualDirectoryServices { /// <summary> /// IIS属性类 /// </summary> public class VirtualDirectory { private string _Name; private string _Path; private string _AppFriendlyName; private string _UNCUsername; private string _UNCPassword; private bool _AccessRead; private bool _AccessWrite; private bool _AccessExecute; private bool _AccessScript; private bool _DontLog; private bool _ContentIndexed; private bool _EnableDirBrowsing; private int _AppIsolated; /// <summary>构造函数1</summary> /// <param name="strVirDirName">虚拟目录名称</param> /// <param name="strPhyPath">虚拟目录所指向的路径</param> public VirtualDirectory(string strVirDirName, string strPhyPath) { _Name = strVirDirName; _AppFriendlyName = strVirDirName; _Path = strPhyPath; // 内置UNC账户 _UNCUsername = "UNCAccount"; _UNCPassword = "123456"; _AccessRead = true; _AccessWrite = false; _AccessExecute = false; _AccessScript = true; _DontLog = false; _ContentIndexed = true; _EnableDirBrowsing = false; _AppIsolated = 2; } /// <summary>构造函数2,可设置UNC账户</summary> /// <param name="strVirDirName">虚拟目录名称</param> /// <param name="strPhyPath">虚拟目录所指向的路径</param> /// <param name="strUNCAccount"> /// UNC共享虚拟目录账户,strUNCAccount[0]为账户名,strUNCAccount[1]为账户密码 /// </param> public VirtualDirectory(string strVirDirName, string strPhyPath, string[] strUNCAccount) { _Name = strVirDirName; _AppFriendlyName = strVirDirName; _Path = strPhyPath; _UNCUsername = strUNCAccount[0]; _UNCPassword = strUNCAccount[1]; _AccessRead = true; _AccessWrite = false; _AccessExecute = false; _AccessScript = true; _DontLog = false; _ContentIndexed = true; _EnableDirBrowsing = false; _AppIsolated = 2; } /// <value> /// 虚拟目录名称属性,例如Picture、Audio、Video。 /// </value> public string Name { get { return _Name; } set { _Name = value; } } /// <value> /// 应用程序名称属性<br/> /// 虚拟目录的描述性文字,例如Picture:图片文件夹。 /// </value> public string AppFriendlyName { get { return _AppFriendlyName; } set { _AppFriendlyName = value; } } /// <value> /// 物理(网络)路径属性<br/> /// 形如"D:\files\picture","\\192.168.89.244\picture"。 /// </value> public string Path { get { return _Path; } set { _Path = value; } } 下一篇《基于DirectoryServices的IIS虚拟目录管理(2)》

评论