BufferedStream.CanWrite 屬性

定義

取得表示目前資料流是否支援寫入的值。Gets a value indicating whether the current stream supports writing.

public:
 virtual property bool CanWrite { bool get(); };
public override bool CanWrite { get; }
member this.CanWrite : bool
Public Overrides ReadOnly Property CanWrite As Boolean

屬性值

如果資料流支援寫入,則為 true;如果資料流已關閉或以唯讀存取開啟,則為 falsetrue if the stream supports writing; false if the stream is closed or was opened with read-only access.

範例

這個程式碼範例是針對 BufferedStream 類別所提供的較大範例的一部分。This code example is part of a larger example provided for the BufferedStream class.

if ( bufStream->CanWrite )
{
   Client::SendData( netStream, bufStream );
}

if(bufStream.CanWrite)
{
    SendData(netStream, bufStream);
}
If bufStream.CanWrite Then
    SendData(netStream, bufStream)
End If            

備註

如果衍生自 Stream 的類別不支援寫入,SetLengthWriteWriteByte 的呼叫會擲回 NotSupportedExceptionIf a class derived from Stream does not support writing, a call to SetLength, Write, or WriteByte throws a NotSupportedException.

如果資料流程已關閉,此屬性會傳回 falseIf the stream is closed, this property returns false.

適用於

另請參閱