다음을 통해 공유


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 은 다음 표와 같이 큐 유형에 따라 달라집니다.

큐 유형 문법
공용 큐 MachineName\QueueName

Exists(String) 를 호출하여 원격 프라이빗 큐가 있는지 확인할 수 없습니다.

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

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

참조 문법
라벨 레이블:[ label ]

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

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

적용 대상

추가 정보