对虚拟目录的操作
来源:互联网 发布:h5网站制作软件 编辑:程序博客网 时间:2024/05/17 05:12
之前做站点发布的时候,有用到对虚拟目录的操作,今天抽时间整理了一下,大概如下:
一、查看虚拟目录是否存在
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();
}
- 对虚拟目录的操作
- 对虚拟目录的操作
- 对虚拟目录的操作(转)
- 对IIS中的虚拟目录进行操作
- 操作IIS的虚拟目录(C#)
- ASP.NET对IIS中的虚拟目录进行操作
- ASP.NET对IIS中的虚拟目录进行操作
- 用ASP.NET对IIS中的虚拟目录进行操作(转)
- 用ASP.NET对IIS中的虚拟目录进行操作(转)
- 用ASP.NET对IIS中的虚拟目录进行操作(转)
- 用ASP.NET对IIS中的虚拟目录进行操作
- 用ASP.NET对IIS中的虚拟目录进行操作
- 用ASP.NET对IIS中的虚拟目录进行操作
- ASP.NET对IIS中的虚拟目录进行操作
- ASP.NET对IIS中的虚拟目录进行操作
- 使用C++操作IIS的虚拟目录
- 使用C++操作IIS的虚拟目录
- 总结一下.net 虚拟目录获得操作最基本的操作
- .NET程序使用资源文件中的光标文件另一招
- 数据结构(续3)
- Oracle9i安装、升级、卸载和使用(Unix)
- Visual C++编程指南 -- 托管C++
- 在redhat linux 下建立ftp服务器
- 对虚拟目录的操作
- 在.NET程序中控制系统音量
- 全球15个顶级技术类博客
- 使用Castle.ActiveRecord的注意事项四:using (new SessionScope(FlushAction.Never))
- 博客园团队列表
- 推荐一个好工具:P/Invoke Interop Assistant
- Getting the right Exception Context from a Memory dump Fixed -- cnblogs
- CLR探索系列:Windbg+SOS剖析揭示域世界 -- cnblog
- CLR探索系列:Windbg+SOS动态调试分析托管代码 -- cnblog