DirectoryEntries.Remove メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DirectoryEntries.Remove メソッドの意味・解説 

DirectoryEntries.Remove メソッド

このコレクションメンバ削除します

名前空間: System.DirectoryServices
アセンブリ: System.DirectoryServices (system.directoryservices.dll 内)
構文構文

Public Sub Remove ( _
    entry As DirectoryEntry _
)
Dim instance As DirectoryEntries
Dim entry As DirectoryEntry

instance.Remove(entry)
public void Remove (
    DirectoryEntry entry
)
public:
void Remove (
    DirectoryEntry^ entry
)
public void Remove (
    DirectoryEntry entry
)
public function Remove (
    entry : DirectoryEntry
)

パラメータ

entry

削除する DirectoryEntry オブジェクトの名前。

例外例外
例外種類条件

COMException

基になるインターフェイス呼び出すときにエラー発生しました

解説解説

削除されるエントリがコンテナである場合、そのコンテナは空である必要がありますコンテナとそのすべての子を削除するには、DeleteTree メソッド使用します

使用例使用例

指定したパスを持つ新しDirectoryEntry オブジェクト作成し、そのコンテナ内に新しいエントリを作成し、それを保存する Visual Basic .NET コード例次に示します最後に新しいエントリを取得し、それを削除します

Imports System
Imports System.DirectoryServices

Class MyClass1
   Shared Sub Main()
      Try
         Dim strPath As String
 = "IIS://localhost/W3SVC/1/Root"
         Dim strName As String
 = ""

         ' Create a new 'DirectoryEntry' object with the given path.
         Dim myDE As New
 DirectoryEntry(strPath)
         Dim myEntries As DirectoryEntries
 = myDE.Children

         ' Create a new entry 'Sample' in the container.
         Dim myDirectoryEntry As DirectoryEntry
 = myEntries.Add("Sample", myDE.SchemaClassName)
         ' Save changes of entry in the 'Active Directory'.
         myDirectoryEntry.CommitChanges()
         Console.WriteLine(myDirectoryEntry.Name + " entry is
 created in container.")

         ' Find 'Sample' entry in container.
         myDirectoryEntry = myEntries.Find("Sample",
 myDE.SchemaClassName)
         Console.WriteLine(myDirectoryEntry.Name + " found in
 container.")
         ' Remove 'Sample' entry from container.
         strName = myDirectoryEntry.Name
         myEntries.Remove(myDirectoryEntry)
         Console.WriteLine(strName + " entry is removed from container.")

      Catch e As Exception
         Console.WriteLine("The following exception was raised
 : {0}", e.Message.ToString())
      End Try
   End Sub 'Main
End Class 'MyClass1

指定したパスを持つ新しDirectoryEntry オブジェクト作成し、そのコンテナ内に新しいエントリを作成し、それを保存する C# コード例次に示します最後に新しいエントリを取得し、それを削除します

using System;
using System.DirectoryServices; 

class MyClass1
{
   static void Main()
   {
      try
      {
         String strPath = "IIS://localhost/W3SVC/1/Root";
         String strName = "";

         // Create a new 'DirectoryEntry' object with the given path.
         DirectoryEntry myDE = new DirectoryEntry(strPath);
         DirectoryEntries myEntries = myDE.Children;

         // Create a new entry 'Sample' in the container.
         DirectoryEntry myDirectoryEntry = 
            myEntries.Add("Sample", myDE.SchemaClassName);
         // Save changes of entry in the 'Active Directory'.
         myDirectoryEntry.CommitChanges();
         Console.WriteLine (myDirectoryEntry.Name + 
            " entry is created in container.");

         // Find 'Sample' entry in container.
         myDirectoryEntry = myEntries.Find("Sample", myDE.SchemaClassName);
         Console.WriteLine(myDirectoryEntry.Name + " found in
 container.");
         // Remove 'Sample' entry from container.
         strName = myDirectoryEntry.Name;
         myEntries.Remove(myDirectoryEntry);
         Console.WriteLine(strName+ " entry is removed from container.");

      }
      catch(Exception e)
      {
         Console.WriteLine("The following exception was raised : {0}",
            e.Message);
      }
   }
}

指定したパスを持つ新しDirectoryEntry オブジェクト作成し、そのコンテナ内に新しいエントリを作成し、それを保存する C++ コード例次に示します最後に新しいエントリを取得し、それを削除します

#using <mscorlib.dll>
#using <System.dll>
#using <System.Directoryservices.dll>

using namespace System;
using namespace System::DirectoryServices;
 

int main() {
    try {
        String* strPath = S"IIS://localhost/W3SVC/1/Root";
        String* strName = S"";

        // Create a new 'DirectoryEntry' object with the given path.
        DirectoryEntry* myDE = new DirectoryEntry(strPath);
        DirectoryEntries* myEntries = myDE->Children;

        // Create a new entry 'Sample' in the container.
        DirectoryEntry* myDirectoryEntry =  myEntries->Add(S"Sample",
 myDE->SchemaClassName);
        // Save changes of entry in the 'Active Directory'.
        myDirectoryEntry->CommitChanges();
        Console::WriteLine(S"{0} entry is created in container.",
 myDirectoryEntry->Name);

        // Find 'Sample' entry in container.
        myDirectoryEntry = myEntries->Find(S"Sample", myDE->SchemaClassName);
        Console::WriteLine(S"{0} found in container.",
 myDirectoryEntry->Name);
        // Remove 'Sample' entry from container.
        strName = myDirectoryEntry->Name;
        myEntries->Remove(myDirectoryEntry);
        Console::WriteLine(S"{0} entry is removed from container.", strName);
    } catch(Exception* e) {
        Console::WriteLine(S"The following exception was raised : {0}",
 e->Message);
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

DirectoryEntries.Remove メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DirectoryEntries.Remove メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS