MessageQueue.Delete(String) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
刪除 Message Queuing 伺服器上的佇列。
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
或空字串 ("")。
範例
如果消息佇列佇列存在,下列程式代碼範例會刪除它。
#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:[ format name ] |
標籤 | Label:[ label ] |
下表顯示此方法是否可在各種工作組模式中使用。
工作組模式 | 可用 |
---|---|
本機電腦 | 是 |
本機計算機和直接格式名稱 | 是 |
遠端電腦 | 否 |
遠端電腦和直接格式名稱 | 否 |