HttpListenerPrefixCollection.Clear Metoda

Definice

Odebere všechny předpony URI (Uniform Resource Identifier) z kolekce.

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

Implementuje

Výjimky

Volání funkce Windows se nezdařilo. Zkontrolujte vlastnost výjimky ErrorCode a určete příčinu výjimky.

Přidružený HttpListener k této kolekci je uzavřen.

Příklady

Následující příklad kódu odebere všechny předpony v objektu 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

Poznámky

Po volání této metody nelze spustit přidružené HttpListener bez přidání nových předpon; pokud se o to pokusíte, je vyvolán výjimka.

Poznámky pro volající

Tento člen poskytuje trasovací informace, když je ve vaší aplikaci povoleno trasování sítě. Další informace naleznete v tématu Trasování sítě v rozhraní .NET Framework.

Platí pro

Viz také