NegotiateStream.CanWrite 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个 Boolean 值,该值指示基础流是否可写。
public:
virtual property bool CanWrite { bool get(); };
public override bool CanWrite { get; }
member this.CanWrite : bool
Public Overrides ReadOnly Property CanWrite As Boolean
属性值
如果已进行身份验证且基础流可写,则为 true
;否则为 false
。
示例
下面的代码示例演示如何显示此属性的值。
static void DisplayStreamProperties( NegotiateStream^ stream )
{
Console::WriteLine( L"Can read: {0}", stream->CanRead );
Console::WriteLine( L"Can write: {0}", stream->CanWrite );
Console::WriteLine( L"Can seek: {0}", stream->CanSeek );
try
{
// If the underlying stream supports it, display the length.
Console::WriteLine( L"Length: {0}", stream->Length );
}
catch ( NotSupportedException^ )
{
Console::WriteLine( L"Cannot get the length of the underlying stream." );
}
if ( stream->CanTimeout )
{
Console::WriteLine( L"Read time-out: {0}", stream->ReadTimeout );
Console::WriteLine( L"Write time-out: {0}", stream->WriteTimeout );
}
}
static void DisplayStreamProperties(NegotiateStream stream)
{
Console.WriteLine("Can read: {0}", stream.CanRead);
Console.WriteLine("Can write: {0}", stream.CanWrite);
Console.WriteLine("Can seek: {0}", stream.CanSeek);
try
{
// If the underlying stream supports it, display the length.
Console.WriteLine("Length: {0}", stream.Length);
} catch (NotSupportedException)
{
Console.WriteLine("Cannot get the length of the underlying stream.");
}
if (stream.CanTimeout)
{
Console.WriteLine("Read time-out: {0}", stream.ReadTimeout);
Console.WriteLine("Write time-out: {0}", stream.WriteTimeout);
}
}
注解
如果身份验证成功,此属性将返回通过调用 CanWrite 基础流上的 属性返回的值。 基础流是在创建 类的 NegotiateStream 实例时指定的。