HttpListenerPrefixCollection.Clear Metoda

Definicja

Usuwa wszystkie prefiksy identyfikatora URI (Uniform Resource Identifier) z kolekcji.

public:
 virtual void Clear();
public void Clear ();
abstract member Clear : unit -> unit
override this.Clear : unit -> unit
Public Sub Clear ()

Implementuje

Wyjątki

Wywołanie funkcji systemu Windows nie powiodło się. Sprawdź właściwość wyjątku ErrorCode , aby określić przyczynę wyjątku.

Skojarzona HttpListener z tą kolekcją jest zamknięta.

Przykłady

Poniższy przykład kodu usuwa wszystkie prefiksy w obiekcie HttpListenerPrefixCollection.

public static bool RemoveAllPrefixes(HttpListener listener)
{
    // Get the prefixes that the Web server is listening to.
    HttpListenerPrefixCollection prefixes = listener.Prefixes;
    try
    {
        prefixes.Clear();
    }
    // If the operation failed, return false.
    catch
    {
        return false;
    }
    return true;
}
Public Shared Function RemoveAllPrefixes(ByVal listener As HttpListener) As Boolean
    ' Get the prefixes that the Web server is listening to.
    Dim prefixes As HttpListenerPrefixCollection = listener.Prefixes

    Try
        prefixes.Clear()
    Catch ' If the operation failed, return false.
        Return False
    End Try

    Return True
End Function

Uwagi

Po wywołaniu tej metody nie można uruchomić skojarzonego elementu HttpListener bez dodawania nowych prefiksów. Jeśli spróbujesz to zrobić, zostanie zgłoszony wyjątek.

Uwagi dotyczące wywoływania

Ten element członkowski generuje informacje ze śledzenia pod warunkiem włączenia funkcji śledzenia sieci w aplikacji. Aby uzyskać więcej informacji, zobacz Śledzenie sieci w .NET Framework.

Dotyczy

Zobacz też