Share via


MessageQueue.Delete(String) Metode

Definisi

Menghapus antrean pada server Antrean Pesan.

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)

Parameter

path
String

Lokasi antrean yang akan dihapus.

Pengecualian

Parameternya path adalah null atau adalah string kosong ("").

Sintaks untuk path parameter tidak valid.

-atau-

Terjadi kesalahan saat mengakses metode Antrean Pesan.

Contoh

Contoh kode berikut menghapus antrean Antrean Pesan, jika ada.

#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

Keterangan

Sintaks untuk path parameter tergantung pada jenis antrean.

Jenis antrean Sintaks
Antrean publik MachineName\QueueName
Antrean privat MachineName\Private$\QueueName

Untuk sintaks lainnya, lihat Path properti .

Atau, Anda dapat menggunakan FormatName atau Label untuk menjelaskan jalur antrean.

Referensi Sintaks
Nama format FormatName:[ format name ]
Label Label:[ label ]

Tabel berikut menunjukkan apakah metode ini tersedia dalam berbagai mode Grup Kerja.

Mode grup kerja Tersedia
Komputer lokal Ya
Komputer lokal dan nama format langsung Ya
Komputer jarak jauh Tidak
Komputer jarak jauh dan nama format langsung Tidak

Berlaku untuk

Lihat juga