Stream Stream Stream Stream Class

定義

提供位元組順序的一般觀點。Provides a generic view of a sequence of bytes. 這是 abstract 類別。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.

某些更常用的資料流,繼承自StreamFileStream,和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. 您可以使用,以查詢其功能的資料流CanReadCanWrite,並CanSeek的屬性Stream類別。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方法和PositionLength查詢及修改目前的位置和長度資料流的屬性。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. 若要直接處置型別,呼叫其Dispose方法中的try / catch區塊。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名稱,例如ReadAsyncWriteAsyncCopyToAsync,和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. 非同步方法會用於搭配asyncawaitVisual Basic 和 C# 中的關鍵字。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包含兩個擴充方法:AsInputStreamAsOutputStreamWhen used in a Windows 8.x 市集Windows 8.x Store app, Stream includes two extension methods: AsInputStream and AsOutputStream. 這些方法會轉換Stream物件中的資料流Windows 執行階段Windows RuntimeThese methods convert a Stream object to a stream in the Windows 執行階段Windows Runtime. 您也可以轉換中的資料流Windows 執行階段Windows RuntimeStream使用的物件AsStreamForReadAsStreamForWrite方法。You 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)WriteAsync(Byte[], Int32, Int32),並CopyToAsync(Stream)使用同步方法Read(Byte[], Int32, Int32)Write(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)建立新的單一元素位元組陣列,並接著呼叫您實作Read(Byte[], Int32, Int32)Write(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. 您也必須提供實作CanReadCanSeekCanWriteFlush()LengthPositionSeek(Int64, SeekOrigin),以及SetLength(Int64)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. 如需詳細資訊,請參閱 <<c0> 實作 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)
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)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。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 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the Stream and optionally releases the managed resources.

DisposeAsync() DisposeAsync() DisposeAsync() DisposeAsync()
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()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。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>)
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)
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>)
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)
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.

Extension Methods

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.

適用於

另請參閱