MessageQueue.Delete(String) Metoda

Definicja

Usuwa kolejkę na serwerze kolejkowania komunikatów.

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)

Parametry

path
String

Lokalizacja kolejki do usunięcia.

Wyjątki

Parametr path to null lub jest pustym ciągiem ("").

Składnia parametru path jest nieprawidłowa.

-lub- Wystąpił błąd podczas uzyskiwania dostępu do metody kolejkowania komunikatów.

Przykłady

Poniższy przykład kodu usuwa kolejkę kolejkowania komunikatów, jeśli istnieje.

#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

Uwagi

Składnia parametru path zależy od typu kolejki.

Typ kolejki Składnia
Kolejka publiczna MachineName\QueueName
Kolejka prywatna MachineName\Private$\QueueName

Aby uzyskać więcej składni, zobacz Path właściwość .

Alternatywnie możesz użyć elementu FormatName lub Label , aby opisać ścieżkę kolejki.

Odwołanie Składnia
Nazwa formatu FormatName:[ nazwa formatu ]
Etykieta Etykieta:[ etykieta ]

W poniższej tabeli przedstawiono, czy ta metoda jest dostępna w różnych trybach grupy roboczej.

Tryb grupy roboczej Dostępne
Komputer lokalny Tak
Nazwa komputera lokalnego i bezpośredniego formatu Tak
Komputer zdalny Nie
Nazwa komputera zdalnego i bezpośredniego formatu Nie

Dotyczy

Zobacz też