MessageQueue.Exists(String) 메서드

정의

지정된 경로에 메시지 큐가 있는지 여부를 확인합니다.

public:
 static bool Exists(System::String ^ path);
public static bool Exists (string path);
static member Exists : string -> bool
Public Shared Function Exists (path As String) As Boolean

매개 변수

path
String

찾을 큐의 위치입니다.

반환

지정된 경로에 큐가 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.

예외

path 구문이 잘못되었습니다.

메시지 큐 메서드에 액세스하는 동안 오류가 발생한 경우

또는

Exists(String) 메서드가 원격 프라이빗 큐에서 호출되는 경우

큐가 있는지 여부를 확인할 때 애플리케이션이 형식 이름 구문을 사용했습니다.

예제

다음 코드 예제에서는 메시지 큐가 존재 하 고 다음 삭제 여부를 확인 합니다.

#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;
int main()
{
   
   // Determine whether the queue exists.
   if ( MessageQueue::Exists( ".\\myQueue" ) )
   {
      try
      {
         
         // Delete the queue.
         MessageQueue::Delete( ".\\myQueue" );
      }
      catch ( MessageQueueException^ e ) 
      {
         if ( e->MessageQueueErrorCode == MessageQueueErrorCode::AccessDenied )
         {
            Console::WriteLine( "Access is denied. Queue might be a system queue." );
         }
         
         // Handle other sources of MessageQueueException.
      }

   }

   return 0;
}
using System;
using System.Messaging;

namespace MyProject
{
    /// <summary>
    /// Provides a container class for the example.
    /// </summary>
    public class MyNewQueue
    {

        //**************************************************
        // Provides an entry point into the application.
        //		
        // This example verifies existence and attempts to
        // delete a queue.
        //**************************************************

        public static void Main()
        {

            // Determine whether the queue exists.
            if (MessageQueue.Exists(".\\myQueue"))
            {
                try
                {
                    // Delete the queue.
                    MessageQueue.Delete(".\\myQueue");
                }
                catch(MessageQueueException e)
                {
                    if(e.MessageQueueErrorCode ==
                        MessageQueueErrorCode.AccessDenied)
                    {
                        Console.WriteLine("Access is denied. " +
                            "Queue might be a system queue.");
                    }

                    // Handle other sources of MessageQueueException.
                }
            }
        
            return;
        }
    }
}
Imports System.Messaging



Public Class MyNewQueue


        
        ' Provides an entry point into the application.
        '		 
        ' This example verifies existence and attempts to 
        ' delete a queue.
        

        Public Shared Sub Main()

            ' Determine whether the queue exists.
            If MessageQueue.Exists(".\myQueue") Then

                Try

                    ' Delete the queue.
                    MessageQueue.Delete(".\myQueue")

                Catch e As MessageQueueException

                    If e.MessageQueueErrorCode = _
                        MessageQueueErrorCode.AccessDenied Then

                        Console.WriteLine("Access is denied. " _
                            + "Queue might be a system queue.")
                    End If

                    ' Handle other sources of exceptions as necessary.

                End Try

            End If


            Return

        End Sub

End Class

설명

메서드는 Exists(String) 메시지 큐 큐가 지정된 경로에 있는지 여부를 결정합니다. 지정된 형식 이름을 가진 큐가 있는지 여부를 확인하는 메서드가 없습니다. 형식 이름 구문 및 기타 경로 구문 양식에 대한 자세한 내용은 속성을 참조 Path 하세요.)

Exists(String) 은 비용이 많이 드는 작업입니다. 애플리케이션 내에서 필요한 경우에 사용 합니다.

참고

메서드는 Exists(String) 접두사를 FormatName 지원하지 않습니다.

매개 변수의 구문 path 은 다음 표와 같이 큐 유형에 따라 달라집니다.

큐 유형 Syntax
공개 큐 MachineName\QueueName

Exists(String) 를 호출하여 원격 프라이빗 큐의 존재를 확인할 수 없습니다.

자세한 구문은 속성을 참조 Path 하세요.

또는 를 사용하여 Label 큐 경로를 설명할 수 있습니다.

참조 구문
레이블 Label:[ label ]

다음 표에서는 이 메서드를 다양한 작업 그룹 모드에서 사용할 수 있는지 여부를 보여 줍니다.

작업 그룹 모드 사용 가능
수집 Yes
로컬 컴퓨터 및 직접 형식 이름 No
원격 컴퓨터 No
원격 컴퓨터 및 직접 형식 이름 No

적용 대상

추가 정보