HttpListenerPrefixCollection.Clear 메서드

정의

컬렉션에서 URI(Uniform Resource Identifier) 접두사를 모두 제거합니다.

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

구현

예외

Windows 함수 호출이 실패한 경우. 예외의 ErrorCode 속성을 검토하여 예외의 원인을 확인할 수 있습니다.

이 컬렉션과 연결된 HttpListener는 닫힙니다.

예제

다음 코드 예제에서는 의 모든 접두사를 제거합니다 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

설명

이 메서드를 호출한 후에는 새 접두사를 추가하지 않고는 HttpListener 연결된 을 시작할 수 없습니다. 이렇게 하려고 하면 예외가 throw됩니다.

호출자 참고

애플리케이션에 네트워크 추적을 사용하도록 설정하면 이 멤버에서 추적 정보를 출력합니다. 자세한 내용은 .NET Framework 네트워크 추적을 참조하세요.

적용 대상

추가 정보