MessageQueue.Exists(String) メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定したパスにメッセージ キューが存在するかどうかを判断します。
public:
static bool Exists(System::String ^ path);
public static bool Exists(string path);
static member Exists : string -> bool
Public Shared Function Exists (path As String) As Boolean
パラメーター
- path
- String
検索するキューの場所。
返品
true 指定したパスを持つキューが存在する場合。それ以外の場合は false。
例外
path構文が無効です。
アプリケーションは、キューの存在を確認するときに形式名の構文を使用しました。
例
次のコード例では、メッセージ キューキューが存在するかどうかを確認し、それを削除します。
#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
注釈
Exists(String) メソッドは、メッセージ キュー キューが指定されたパスに存在するかどうかを決定します。 指定した形式名のキューが存在するかどうかを判断するメソッドは存在しません。 書式名の構文とその他のパス構文の形式の詳細については、 Path プロパティを参照してください)。
Exists(String) はコストの高い操作です。 アプリケーション内で必要な場合にのみ使用します。
Note
Exists(String) メソッドは、FormatName プレフィックスをサポートしていません。
path パラメーターの構文は、次の表に示すように、キューの種類によって異なります。
| [キューの種類] | 構文 |
|---|---|
| パブリック キュー | MachineName\QueueName |
Exists(String) リモート プライベート キューの存在を確認するために呼び出すことはできません。
構文の詳細については、 Path プロパティを参照してください。
または、 Label を使用してキュー パスを記述することもできます。
| Reference | 構文 |
|---|---|
| Label | Label:[ label ] |
次の表は、このメソッドがさまざまなワークグループ モードで使用できるかどうかを示しています。
| ワークグループ モード | 在庫有り |
|---|---|
| ローカル コンピューター | はい |
| ローカル コンピューターと直接の形式名 | いいえ |
| リモート コンピューター | いいえ |
| リモート コンピューターと直接の形式名 | いいえ |