Share via


删除目录对象

为了删除目录对象,DirectoryEntries 类提供了 Remove 方法。此方法从当前父 DirectoryEntry 对象的 Children 集合中删除子项。此方法只能用于空容器或未用作目录树的容器(如打印机或计算机节点)的对象。有关删除具有子对象的容器的信息,请参阅删除对象的子树

下面的示例说明如何从目录中删除对象。

Dim entry As New DirectoryServices.DirectoryEntry("WinNT://DomainName")
Dim entryToRemove As DirectoryServices.DirectoryEntry

' Add code here to set entryToRemove to the entry you want to remove.
entry.Children.Remove(entryToRemove)
System.DirectoryServices.DirectoryEntry entry = 
   new System.DirectoryServices.DirectoryEntry("WinNT://DomainName");
System.DirectoryServices.DirectoryEntry entryToRemove = null;

// Add code here to set entryToRemove to the entry you want to remove.
entry.Children.Remove(entryToRemove);

另请参见

参考

System.DirectoryServices
DirectoryEntry
DirectoryEntries

概念

创建、删除、重命名和移动对象
删除对象的子树

Send comments about this topic to Microsoft.

版权所有 (C) 2007 Microsoft Corporation。保留所有权利。