Поделиться через


MessageQueue.Delete(String) Метод

Определение

Удаляет очередь на сервере очереди сообщений.

public:
 static void Delete(System::String ^ path);
public static void Delete(string path);
static member Delete : string -> unit
Public Shared Sub Delete (path As String)

Параметры

path
String

Расположение очереди для удаления.

Исключения

Параметр path имеет или является null пустой строкой ("").

Недопустимый path синтаксис параметра.

–или–

Произошла ошибка при доступе к методу очереди сообщений.

Примеры

В следующем примере кода удаляется очередь очереди очереди сообщений, если она существует.

#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

Комментарии

Синтаксис параметра path зависит от типа очереди.

Тип очереди Синтаксис
Общедоступная очередь MachineName\QueueName
Частная очередь MachineName\Private$\QueueName

Дополнительные сведения о синтаксисе см. в свойстве Path .

Кроме того, можно использовать FormatName или Label описать путь очереди.

Справочные материалы Синтаксис
Имя формата FormatName:[ имя формата ]
Этикетка Метка:[ метка ]

В следующей таблице показано, доступен ли этот метод в различных режимах рабочей группы.

Режим рабочей группы В наличии
Локальный компьютер Да
Имя локального компьютера и прямого формата Да
Удаленный компьютер Нет
Имя удаленного компьютера и прямого формата Нет

Применяется к

См. также раздел