Export (0) Print
Expand All

MessageQueue.CanWrite Property

Gets a value that indicates whether the MessageQueue can be written to.

Namespace:  System.Messaging
Assembly:  System.Messaging (in System.Messaging.dll)

public bool CanWrite { get; }

Property Value

Type: System.Boolean
true if the MessageQueue exists and the application can write to it; otherwise, false.

CanWrite indicates whether the application is able to send messages to the queue. If CanWrite is true, the MessageQueue can send messages to the queue. Otherwise, it cannot.

CanWrite is false if a queue is already open with exclusive write access (or if it's open with non-exclusive access and this MessageQueue requests exclusive access), or if the application does not have sufficient rights to access it. If your application tries to write to a queue when CanWrite is false, access is denied.

The following table shows whether this property is available in various Workgroup modes.

Workgroup mode


Local computer


Local computer and direct format name


Remote computer


Remote computer and direct format name


The following code example displays the value of a message queue's CanWrite property.

// Display the value of the queue's CanWrite property.
Console.WriteLine("MessageQueue.CanWrite: {0}", queue.CanWrite);

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft