MessageQueue.Delete(String) Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
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á se má odstranit.
Výjimky
Parametr path je nebo je null prázdný řetězec ("").
Syntaxe parametru path není platná.
nebo
Při přístupu k metodě ří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 | Syntaxe |
|---|---|
| Veřejná fronta | MachineName\QueueName |
| Soukromá fronta | MachineName\Private$\QueueName |
Další syntaxi najdete v Path této vlastnosti.
Případně můžete použít cestu fronty FormatName nebo Label ji popsat.
| Referenční informace | Syntaxe |
|---|---|
| Název formátu | FormatName:[ název formátu ] |
| Štítek | 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č | Ano |
| Název místního počítače a přímého formátu | Ano |
| Vzdálený počítač | Ne |
| Název vzdáleného počítače a přímého formátu | Ne |