Condividi tramite


MessageQueue.Delete(String) Metodo

Definizione

Elimina una coda in un server accodamento messaggi.

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)

Parametri

path
String

Posizione della coda da eliminare.

Eccezioni

Il path parametro è o è null una stringa vuota ("").

La sintassi per il path parametro non è valida.

oppure

Si è verificato un errore durante l'accesso a un metodo di accodamento messaggi.

Esempio

Nell'esempio di codice seguente viene eliminata una coda di accodamento messaggi, se esistente.

#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

Commenti

La sintassi per il path parametro dipende dal tipo di coda.

Tipo di coda Sintassi
Coda pubblica MachineName\QueueName
Coda privata MachineName\Private$\QueueName

Per altre sintassi, vedere la Path proprietà .

In alternativa, è possibile usare o FormatNameLabel per descrivere il percorso della coda.

Riferimento Sintassi
Nome formato FormatName:[ format name ]
Etichetta Label:[ label ]

Nella tabella seguente viene illustrato se questo metodo è disponibile in varie modalità gruppo di lavoro.

Modalità gruppo di lavoro Disponibile
Computer locale
Computer locale e nome del formato diretto
Computer remoto No
Computer remoto e nome del formato diretto No

Si applica a

Vedi anche