MessageQueue.Delete(String) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Tar bort en kö på en Message Queuing-server.
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)
Parametrar
- path
- String
Platsen för kön som ska tas bort.
Undantag
Parametern path är null eller är en tom sträng ("").
Syntaxen för parametern path är ogiltig.
-eller-
Ett fel uppstod vid åtkomst till en Message Queuing-metod.
Exempel
I följande kodexempel tas en Message Queuing-kö bort, om den finns.
#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
Kommentarer
Syntaxen för parametern path beror på typen av kö.
| Kötyp | Syntax |
|---|---|
| Offentlig kö | MachineName\QueueName |
| Privat kö | MachineName\Private$\QueueName |
Mer syntax finns i egenskapen Path .
Du kan också använda FormatName eller Label för att beskriva kösökvägen.
| Reference | Syntax |
|---|---|
| Formatnamn | FormatName:[ formatnamn ] |
| Label | Etikett:[ etikett ] |
I följande tabell visas om den här metoden är tillgänglig i olika arbetsgruppslägen.
| Arbetsgruppsläge | Tillgängligt |
|---|---|
| Lokal dator | Yes |
| Namn på lokal dator och direktformat | Yes |
| Fjärrdator | No |
| Namn på fjärrdator och direktformat | No |