MessageQueue.Delete(String) Metoda

Definice

Odstraní frontu na serveru služby Řízení front zpráv.

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

Umístění fronty, která má být odstraněna.

Výjimky

Parametr path je null nebo je prázdný řetězec ("").

Syntaxe parametru path není platná.

-nebo-

Při přístupu k metodě služby Řízení front zpráv došlo k chybě.

Příklady

Následující příklad kódu odstraní frontu služby Řízení front zpráv, pokud existuje.

#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

Poznámky

Syntaxe parametru path závisí na typu fronty.

Typ fronty Syntax
Veřejná fronta MachineName\QueueName
Soukromá fronta MachineName\Private$\QueueName

Další syntaxi najdete v tématu vlastnost Path .

Alternativně můžete k popisu cesty fronty použít FormatName nebo Label .

Reference Syntax
Název formátu FormatName:[ název formátu ]
Popisek Popisek:[ popisek ]

Následující tabulka ukazuje, zda je tato metoda k dispozici v různých režimech pracovní skupiny.

Režim pracovní skupiny K dispozici.
Místní počítač Yes
Název místního počítače a přímého formátu Yes
Vzdálený počítač No
Název vzdáleného počítače a přímého formátu No

Platí pro

Viz také