Aracılığıyla paylaş


MessageQueue.Exists(String) Yöntem

Tanım

Bir Message Queuing kuyruğunun belirtilen yolda var olup olmadığını belirler.

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

Parametreler

path
String

Bulunacak kuyruğun konumu.

Döndürülenler

true belirtilen yola sahip bir kuyruk varsa; aksi takdirde , false.

Özel durumlar

Söz path dizimi geçerli değil.

Message Queuing yöntemine erişilirken bir hata oluştu.

-veya-

Exists(String) yöntemi uzak bir özel kuyrukta çağrılır

Uygulama, kuyruk varlığını doğrularken biçim adı söz dizimini kullandı.

Örnekler

Aşağıdaki kod örneği bir Message Queuing kuyruğunun mevcut olup olmadığını doğrular ve ardından siler.

#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

Açıklamalar

yöntemi, Exists(String) bir Message Queuing kuyruğunun belirtilen yolda var olup olmadığını belirler. Belirtilen biçim adına sahip bir kuyruğun mevcut olup olmadığını belirlemek için bir yöntem yok. Biçim adı söz dizimi ve diğer yol söz dizimi formları hakkında daha fazla bilgi için özelliğine Path bakın.)

Exists(String) pahalı bir işlemdir. Yalnızca uygulama içinde gerekli olduğunda kullanın.

Uyarı

Exists(String) yöntemi ön eki desteklemezFormatName.

Parametresinin path söz dizimi, aşağıdaki tabloda gösterildiği gibi kuyruğun türüne bağlıdır.

Kuyruk türü Sözdizimi
Genel kuyruk MachineName\QueueName

Exists(String) uzak özel kuyruğun varlığını doğrulamak için çağrılamaz.

Daha fazla söz dizimi için özelliğine Path bakın.

Alternatif olarak, kuyruk yolunu açıklamak için öğesini Label kullanabilirsiniz.

Referans Sözdizimi
Etiket Etiket:[ label ]

Aşağıdaki tabloda, bu yöntemin çeşitli Çalışma Grubu modlarında kullanılabilir olup olmadığı gösterilmektedir.

Çalışma grubu modu Mevcut
Yerel bilgisayar Evet
Yerel bilgisayar ve doğrudan biçim adı Hayır
Uzak bilgisayar Hayır
Uzak bilgisayar ve doğrudan biçim adı Hayır

Şunlara uygulanır

Ayrıca bkz.