共用方式為


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 並不適用。

-或-

存取訊息佇列方法時發生錯誤。

範例

以下程式碼範例刪除訊息佇列(Message Queuing)佇列(若存在的話)。

#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 or Label 來描述佇列路徑。

Reference 語法
格式名稱 格式名稱:[ 格式名稱 ]
標籤 唱片公司:[ 標籤 ]

下表顯示此方法是否可在多種工作群組模式中使用。

工作群組模式 有現貨
本機電腦 是的
本地電腦與直接格式名稱 是的
遠端電腦 No
遠端電腦與直接格式名稱 No

適用於

另請參閱