Stream Stream Stream Stream Class

定义

提供字节序列的一般视图。Provides a generic view of a sequence of bytes. 这是一个抽象类。This is an abstract class.

public ref class Stream abstract : MarshalByRefObject, IDisposable
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public abstract class Stream : MarshalByRefObject, IDisposable
type Stream = class
    inherit MarshalByRefObject
    interface IDisposable
Public MustInherit Class Stream
Inherits MarshalByRefObject
Implements IDisposable
继承
派生
属性
实现

示例

下面的示例演示如何使用两个FileStream对象将文件从一个目录异步复制到另一个目录。The following example demonstrates how to use two FileStream objects to asynchronously copy the files from one directory to another directory. FileStream 类是从 Stream 类派生的。The FileStream class derives from the Stream class. 需要注意 Click 控件的 Button 事件处理程序具有 async 修饰符标记,因为它调用异步方法。Notice that the Click event handler for the Button control is marked with the async modifier because it calls an asynchronous method.

using System;
using System.Threading.Tasks;
using System.Windows;
using System.IO;

namespace WpfApplication
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string StartDirectory = @"c:\Users\exampleuser\start";
            string EndDirectory = @"c:\Users\exampleuser\end";

            foreach (string filename in Directory.EnumerateFiles(StartDirectory))
            {
                using (FileStream SourceStream = File.Open(filename, FileMode.Open))
                {
                    using (FileStream DestinationStream = File.Create(EndDirectory + filename.Substring(filename.LastIndexOf('\\'))))
                    {
                        await SourceStream.CopyToAsync(DestinationStream);
                    }
                }
            }
        }
    }
}
Imports System.IO

Class MainWindow

    Private Async Sub Button_Click(sender As Object, e As RoutedEventArgs)
        Dim StartDirectory As String = "c:\Users\exampleuser\start"
        Dim EndDirectory As String = "c:\Users\exampleuser\end"

        For Each filename As String In Directory.EnumerateFiles(StartDirectory)
            Using SourceStream As FileStream = File.Open(filename, FileMode.Open)
                Using DestinationStream As FileStream = File.Create(EndDirectory + filename.Substring(filename.LastIndexOf("\"c)))
                    Await SourceStream.CopyToAsync(DestinationStream)
                End Using

            End Using
        Next
    End Sub

End Class

注解

Stream所有流的抽象基类。Stream is the abstract base class of all streams. 流是字节序列的抽象,例如文件、输入/输出设备、进程中通信管道或 TCP/IP 套接字。A stream is an abstraction of a sequence of bytes, such as a file, an input/output device, an inter-process communication pipe, or a TCP/IP socket. Stream类及其派生类提供这些不同类型的输入和输出的一般视图,并将程序员与操作系统和基础设备的具体详细信息隔离开来。The Stream class and its derived classes provide a generic view of these different types of input and output, and isolate the programmer from the specific details of the operating system and the underlying devices.

流涉及三个基本操作:Streams involve three fundamental operations:

  • 可以从流中读取。You can read from streams. 读取是将数据从流传输到数据结构(如字节数组)中。Reading is the transfer of data from a stream into a data structure, such as an array of bytes.

  • 可以写入流。You can write to streams. 写入是指将数据从数据结构传输到流中。Writing is the transfer of data from a data structure into a stream.

  • 流可以支持查找。Streams can support seeking. 查找是指查询和修改流中的当前位置。Seeking refers to querying and modifying the current position within a stream. 查找功能取决于流具有的后备存储的类型。Seek capability depends on the kind of backing store a stream has. 例如,网络流没有当前位置的统一概念,因此通常不支持查找。For example, network streams have no unified concept of a current position, and therefore typically do not support seeking.

继承自Stream的一些常用流是FileStream、和MemoryStreamSome of the more commonly used streams that inherit from Stream are FileStream, and MemoryStream.

根据基础数据源或存储库,流可能只支持其中一些功能。Depending on the underlying data source or repository, streams might support only some of these capabilities. 您可以使用CanRead Stream类的、 CanWriteCanSeek属性查询流的功能。You can query a stream for its capabilities by using the CanRead, CanWrite, and CanSeek properties of the Stream class.

ReadWrite方法读取和写入各种格式的数据。The Read and Write methods read and write data in a variety of formats. 对于支持查找的流,请使用SeekSetLength方法, Position并使用Length和属性来查询和修改流的当前位置和长度。For streams that support seeking, use the Seek and SetLength methods and the Position and Length properties to query and modify the current position and length of a stream.

此类型实现 IDisposable 接口。This type implements the IDisposable interface. 在使用完类型后,您应直接或间接释放类型。When you have finished using the type, you should dispose of it either directly or indirectly. 若要直接释放类型,请在 try/catch 块中调用其 Dispose 方法。To dispose of the type directly, call its Dispose method in a try/catch block. 若要间接释放类型,请使用 using(在 C# 中)或 Using(在 Visual Basic 中)等语言构造。To dispose of it indirectly, use a language construct such as using (in C#) or Using (in Visual Basic). 有关详细信息,请参阅 IDisposable 接口主题中的“使用实现 IDisposable 的对象”一节。For more information, see the "Using an Object that Implements IDisposable" section in the IDisposable interface topic.

释放对象Stream将刷新所有缓冲数据,并在本质上Flush调用方法。Disposing a Stream object flushes any buffered data, and essentially calls the Flush method for you. Dispose还会释放操作系统资源(如文件句柄、网络连接或用于任何内部缓冲的内存)。Dispose also releases operating system resources such as file handles, network connections, or memory used for any internal buffering. BufferedStream类提供了围绕另一个流包装缓冲流以提高读写性能的功能。The BufferedStream class provides the capability of wrapping a buffered stream around another stream in order to improve read and write performance.

.NET Framework 4.5.NET Framework 4.5从开始Stream ,类包括异步方法来简化异步操作。Starting with the .NET Framework 4.5.NET Framework 4.5, the Stream class includes async methods to simplify asynchronous operations. 异步方法在其Async名称中包含, ReadAsync例如、 WriteAsync CopyToAsync、和FlushAsyncAn async method contains Async in its name, such as ReadAsync, WriteAsync, CopyToAsync, and FlushAsync. 利用这些方法,您可以在不阻塞主线程的情况下执行占用大量资源的 i/o 操作。These methods enable you to perform resource-intensive I/O operations without blocking the main thread. Windows 8.x 应用商店Windows 8.x Store 应用或 桌面desktop 应用中一个耗时的流操作可能阻塞 UI 线程并让您的应用看起来好像不工作时,这种性能的考虑就显得尤为重要了。This performance consideration is particularly important in a Windows 8.x 应用商店Windows 8.x Store app or 桌面desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. 在 Visual Basic 和async C#中, async 方法与和await关键字一起使用。The async methods are used in conjunction with the async and await keywords in Visual Basic and C#.

Windows 8.x 应用商店Windows 8.x Store应用中使用时, Stream包括两个扩展方法AsInputStreamAsOutputStream和。When used in a Windows 8.x 应用商店Windows 8.x Store app, Stream includes two extension methods: AsInputStream and AsOutputStream. 这些方法将Stream对象转换为Windows 运行时Windows Runtime中的流。These methods convert a Stream object to a stream in the Windows 运行时Windows Runtime. Windows 运行时Windows Runtime你还可以使用Stream AsStreamForRead和方法将中的流转换为对象。AsStreamForWriteYou can also convert a stream in the Windows 运行时Windows Runtime to a Stream object by using the AsStreamForRead and AsStreamForWrite methods. 有关详细信息,请参阅如何:在 .NET Framework 流和 Windows 运行时流之间进行转换For more information, see How to: Convert Between .NET Framework Streams and Windows Runtime Streams

某些流实现执行基础数据的本地缓冲以提高性能。Some stream implementations perform local buffering of the underlying data to improve performance. 对于此类流,可以使用FlushFlushAsync方法来清除任何内部缓冲区,并确保所有数据都已写入基础数据源或存储库。For such streams, you can use the Flush or FlushAsync method to clear any internal buffers and ensure that all data has been written to the underlying data source or repository.

如果需要一个没有后备存储的流(也称为 "位桶"),请使用Null字段检索为此目的而设计的流的实例。If you need a stream with no backing store (also known as a bit bucket), use the Null field to retrieve an instance of a stream that is designed for this purpose.

继承者说明

实现的Stream派生类时,必须提供Read(Byte[], Int32, Int32)Write(Byte[], Int32, Int32)方法的实现。When you implement a derived class of Stream, you must provide implementations for the Read(Byte[], Int32, Int32) and Write(Byte[], Int32, Int32) methods. ReadAsync(Byte[], Int32, Int32)异步方法Write(Byte[], Int32, Int32)WriteAsync(Byte[], Int32, Int32)CopyToAsync(Stream)在其实现中使用同步Read(Byte[], Int32, Int32)方法。The asynchronous methods ReadAsync(Byte[], Int32, Int32), WriteAsync(Byte[], Int32, Int32), and CopyToAsync(Stream) use the synchronous methods Read(Byte[], Int32, Int32) and Write(Byte[], Int32, Int32) in their implementations. 因此, Read(Byte[], Int32, Int32)Write(Byte[], Int32, Int32)的实现将与异步方法一起正常工作。Therefore, your implementations of Read(Byte[], Int32, Int32) and Write(Byte[], Int32, Int32) will work correctly with the asynchronous methods. ReadByte()默认实现并WriteByte(Byte)创建新的单元素字节数组,然后调用和Write(Byte[], Int32, Int32)Read(Byte[], Int32, Int32)实现。The default implementations of ReadByte() and WriteByte(Byte) create a new single-element byte array, and then call your implementations of Read(Byte[], Int32, Int32) and Write(Byte[], Int32, Int32). Stream派生时,我们建议你重写这些方法,以便访问内部缓冲区(如果有),以显著提高性能。When you derive from Stream, we recommend that you override these methods to access your internal buffer, if you have one, for substantially better performance. CanRead必须提供、 CanSeek CanWriteFlush()、、 、Length 、和SetLength(Int64)的实现。 Position Seek(Int64, SeekOrigin)You must also provide implementations of CanRead, CanSeek, CanWrite, Flush(), Length, Position, Seek(Int64, SeekOrigin), and SetLength(Int64).

不要重写Close()方法,而是将Stream所有清理逻辑放入Dispose(Boolean)方法中。Do not override the Close() method, instead, put all the Stream cleanup logic in the Dispose(Boolean) method. 有关详细信息,请参阅实现 Dispose 方法For more information, see Implementing a Dispose Method.

构造函数

Stream() Stream() Stream() Stream()

初始化 Stream 类的新实例。Initializes a new instance of the Stream class.

字段

Null Null Null Null

无后备存储区的 StreamA Stream with no backing store.

属性

CanRead CanRead CanRead CanRead

当在派生类中重写时,获取指示当前流是否支持读取的值。When overridden in a derived class, gets a value indicating whether the current stream supports reading.

CanSeek CanSeek CanSeek CanSeek

当在派生类中重写时,获取指示当前流是否支持查找功能的值。When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

CanTimeout CanTimeout CanTimeout CanTimeout

获取一个值,该值确定当前流是否可以超时。Gets a value that determines whether the current stream can time out.

CanWrite CanWrite CanWrite CanWrite

当在派生类中重写时,获取指示当前流是否支持写入功能的值。When overridden in a derived class, gets a value indicating whether the current stream supports writing.

Length Length Length Length

当在派生类中重写时,获取流长度(以字节为单位)。When overridden in a derived class, gets the length in bytes of the stream.

Position Position Position Position

当在派生类中重写时,获取或设置当前流中的位置。When overridden in a derived class, gets or sets the position within the current stream.

ReadTimeout ReadTimeout ReadTimeout ReadTimeout

获取或设置一个值(以毫秒为单位),该值确定流在超时前尝试读取多长时间。Gets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out.

WriteTimeout WriteTimeout WriteTimeout WriteTimeout

获取或设置一个值(以毫秒为单位),该值确定流在超时前尝试写入多长时间。Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out.

方法

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)

开始异步读操作。Begins an asynchronous read operation. (请考虑改用 ReadAsync(Byte[], Int32, Int32)。)(Consider using ReadAsync(Byte[], Int32, Int32) instead.)

BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

开始异步写操作。Begins an asynchronous write operation. (请考虑改用 WriteAsync(Byte[], Int32, Int32)。)(Consider using WriteAsync(Byte[], Int32, Int32) instead.)

Close() Close() Close() Close()

关闭当前流并释放与之关联的所有资源(如套接字和文件句柄)。Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. 不直接调用此方法,而应确保流得以正确释放。Instead of calling this method, ensure that the stream is properly disposed.

CopyTo(Stream) CopyTo(Stream) CopyTo(Stream) CopyTo(Stream)

从当前流中读取字节并将其写入到另一流中。Reads the bytes from the current stream and writes them to another stream.

CopyTo(Stream, Int32) CopyTo(Stream, Int32) CopyTo(Stream, Int32) CopyTo(Stream, Int32)

使用指定的缓冲区大小,从当前流中读取字节并将其写入到另一流中。Reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

CopyToAsync(Stream) CopyToAsync(Stream) CopyToAsync(Stream) CopyToAsync(Stream)

从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream.

CopyToAsync(Stream, CancellationToken) CopyToAsync(Stream, CancellationToken) CopyToAsync(Stream, CancellationToken) CopyToAsync(Stream, CancellationToken)

通过指定的取消令牌,从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified cancellation token.

CopyToAsync(Stream, Int32) CopyToAsync(Stream, Int32) CopyToAsync(Stream, Int32) CopyToAsync(Stream, Int32)

使用指定的缓冲区大小,从当前流中异步读取字节并将其写入到另一流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size.

CopyToAsync(Stream, Int32, CancellationToken) CopyToAsync(Stream, Int32, CancellationToken) CopyToAsync(Stream, Int32, CancellationToken) CopyToAsync(Stream, Int32, CancellationToken)

使用指定的缓冲区大小和取消令牌,从当前流中异步读取字节并将其写入到另一个流中。Asynchronously reads the bytes from the current stream and writes them to another stream, using a specified buffer size and cancellation token.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
CreateWaitHandle() CreateWaitHandle() CreateWaitHandle() CreateWaitHandle()

分配 WaitHandle 对象。Allocates a WaitHandle object.

Dispose() Dispose() Dispose() Dispose()

释放由 Stream 使用的所有资源。Releases all resources used by the Stream.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放由 Stream 占用的非托管资源,还可以另外再释放托管资源。Releases the unmanaged resources used by the Stream and optionally releases the managed resources.

DisposeAsync() DisposeAsync() DisposeAsync() DisposeAsync()

异步释放 Stream 使用的非托管资源。Asynchronously releases the unmanaged resources used by the Stream.

EndRead(IAsyncResult) EndRead(IAsyncResult) EndRead(IAsyncResult) EndRead(IAsyncResult)

等待挂起的异步读取完成。Waits for the pending asynchronous read to complete. (请考虑改用 ReadAsync(Byte[], Int32, Int32)。)(Consider using ReadAsync(Byte[], Int32, Int32) instead.)

EndWrite(IAsyncResult) EndWrite(IAsyncResult) EndWrite(IAsyncResult) EndWrite(IAsyncResult)

结束异步写操作。Ends an asynchronous write operation. (请考虑改用 WriteAsync(Byte[], Int32, Int32)。)(Consider using WriteAsync(Byte[], Int32, Int32) instead.)

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Flush() Flush() Flush() Flush()

当在派生类中重写时,将清除该流的所有缓冲区,并使得所有缓冲数据被写入到基础设备。When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

FlushAsync() FlushAsync() FlushAsync() FlushAsync()

异步清除此流的所有缓冲区并导致所有缓冲数据都写入基础设备中。Asynchronously clears all buffers for this stream and causes any buffered data to be written to the underlying device.

FlushAsync(CancellationToken) FlushAsync(CancellationToken) FlushAsync(CancellationToken) FlushAsync(CancellationToken)

异步清理这个流的所有缓冲区,并使所有缓冲数据写入基础设备,并且监控取消请求。Asynchronously clears all buffers for this stream, causes any buffered data to be written to the underlying device, and monitors cancellation requests.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

检索控制此实例的生存期策略的当前生存期服务对象。Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

获取生存期服务对象来控制此实例的生存期策略。Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

创建当前 MarshalByRefObject 对象的浅表副本。Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
ObjectInvariant() ObjectInvariant() ObjectInvariant() ObjectInvariant()

提供对 Contract 的支持。Provides support for a Contract.

Read(Byte[], Int32, Int32) Read(Byte[], Int32, Int32) Read(Byte[], Int32, Int32) Read(Byte[], Int32, Int32)

当在派生类中重写时,从当前流读取字节序列,并将此流中的位置提升读取的字节数。When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

Read(Span<Byte>) Read(Span<Byte>) Read(Span<Byte>) Read(Span<Byte>)

当在派生类中重写时,从当前流读取字节序列,并将此流中的位置提升读取的字节数。When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

ReadAsync(Byte[], Int32, Int32) ReadAsync(Byte[], Int32, Int32) ReadAsync(Byte[], Int32, Int32) ReadAsync(Byte[], Int32, Int32)

从当前流异步读取字节序列,并将流中的位置提升读取的字节数。Asynchronously reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

ReadAsync(Byte[], Int32, Int32, CancellationToken) ReadAsync(Byte[], Int32, Int32, CancellationToken) ReadAsync(Byte[], Int32, Int32, CancellationToken) ReadAsync(Byte[], Int32, Int32, CancellationToken)

从当前流异步读取字节的序列,将流中的位置提升读取的字节数,并监视取消请求。Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

ReadAsync(Memory<Byte>, CancellationToken) ReadAsync(Memory<Byte>, CancellationToken) ReadAsync(Memory<Byte>, CancellationToken) ReadAsync(Memory<Byte>, CancellationToken)

从当前流异步读取字节的序列,将流中的位置提升读取的字节数,并监视取消请求。Asynchronously reads a sequence of bytes from the current stream, advances the position within the stream by the number of bytes read, and monitors cancellation requests.

ReadByte() ReadByte() ReadByte() ReadByte()

从流中读取一个字节,并将流内的位置向前提升一个字节,或者如果已到达流结尾,则返回 -1。Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

Seek(Int64, SeekOrigin) Seek(Int64, SeekOrigin) Seek(Int64, SeekOrigin) Seek(Int64, SeekOrigin)

当在派生类中重写时,设置当前流中的位置。When overridden in a derived class, sets the position within the current stream.

SetLength(Int64) SetLength(Int64) SetLength(Int64) SetLength(Int64)

当在派生类中重写时,设置当前流的长度。When overridden in a derived class, sets the length of the current stream.

Synchronized(Stream) Synchronized(Stream) Synchronized(Stream) Synchronized(Stream)

在指定的 Stream 对象周围创建线程安全(同步)包装。Creates a thread-safe (synchronized) wrapper around the specified Stream object.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
Write(Byte[], Int32, Int32) Write(Byte[], Int32, Int32) Write(Byte[], Int32, Int32) Write(Byte[], Int32, Int32)

当在派生类中重写时,向当前流中写入字节序列,并将此流中的当前位置提升写入的字节数。When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

Write(ReadOnlySpan<Byte>) Write(ReadOnlySpan<Byte>) Write(ReadOnlySpan<Byte>) Write(ReadOnlySpan<Byte>)

当在派生类中重写时,向当前流中写入字节序列,并将此流中的当前位置提升写入的字节数。When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

WriteAsync(Byte[], Int32, Int32) WriteAsync(Byte[], Int32, Int32) WriteAsync(Byte[], Int32, Int32) WriteAsync(Byte[], Int32, Int32)

将字节序列异步写入当前流,并将流的当前位置提升写入的字节数。Asynchronously writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

WriteAsync(Byte[], Int32, Int32, CancellationToken) WriteAsync(Byte[], Int32, Int32, CancellationToken) WriteAsync(Byte[], Int32, Int32, CancellationToken) WriteAsync(Byte[], Int32, Int32, CancellationToken)

将字节的序列异步写入当前流,将该流中的当前位置向前移动写入的字节数,并监视取消请求。Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

将字节的序列异步写入当前流,将该流中的当前位置向前移动写入的字节数,并监视取消请求。Asynchronously writes a sequence of bytes to the current stream, advances the current position within this stream by the number of bytes written, and monitors cancellation requests.

WriteByte(Byte) WriteByte(Byte) WriteByte(Byte) WriteByte(Byte)

将一个字节写入流内的当前位置,并将流内的位置向前提升一个字节。Writes a byte to the current position in the stream and advances the position within the stream by one byte.

显式界面实现

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

释放由 Stream 使用的所有资源。Releases all resources used by the Stream.

扩展方法

AsInputStream(Stream) AsInputStream(Stream) AsInputStream(Stream) AsInputStream(Stream)

将适用于 Windows 应用商店应用的 .NET 中的托管流转换为 Windows 运行时中的输入流。Converts a managed stream in the .NET for Windows Store apps to an input stream in the Windows Runtime.

AsOutputStream(Stream) AsOutputStream(Stream) AsOutputStream(Stream) AsOutputStream(Stream)

将适用于 Windows 应用商店应用的 .NET 中的托管流转换为 Windows 运行时中的输出流。Converts a managed stream in the .NET for Windows Store apps to an output stream in the Windows Runtime.

AsRandomAccessStream(Stream) AsRandomAccessStream(Stream) AsRandomAccessStream(Stream) AsRandomAccessStream(Stream)

将指定的流转换为随机访问流。Converts the specified stream to a random access stream.

适用于

另请参阅