StreamWriter StreamWriter StreamWriter StreamWriter Class

定義

實作以特定的編碼方式將字元寫入位元組資料流的 TextWriterImplements a TextWriter for writing characters to a stream in a particular encoding.

public ref class StreamWriter : System::IO::TextWriter
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class StreamWriter : System.IO.TextWriter
type StreamWriter = class
    inherit TextWriter
Public Class StreamWriter
Inherits TextWriter
繼承
屬性

範例

下列範例示範如何使用StreamWriter物件寫入檔案,列出 C 磁碟機上的目錄,然後使用StreamReader物件來讀取和顯示每個目錄名稱。The following example shows how to use a StreamWriter object to write a file that lists the directories on the C drive, and then uses a StreamReader object to read and display each directory name. 理想的作法是使用中的這些物件using陳述式,以便正確處置 unmanaged 的資源。A good practice is to use these objects in a using statement so that the unmanaged resources are correctly disposed. using陳述式會自動呼叫Dispose物件正在使用它的程式碼完成時。The using statement automatically calls Dispose on the object when the code that is using it has completed. 此範例中使用的建構函式不支援用於Windows 市集Windows Store應用程式。The constructor used in this example is not supported for use in Windows 市集Windows Store Apps.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace StreamReadWrite
{
    class Program
    {
        static void Main(string[] args)
        {
            // Get the directories currently on the C drive.
            DirectoryInfo[] cDirs = new DirectoryInfo(@"c:\").GetDirectories();

            // Write each directory name to a file.
            using (StreamWriter sw = new StreamWriter("CDriveDirs.txt"))
            {
                foreach (DirectoryInfo dir in cDirs)
                {
                    sw.WriteLine(dir.Name);

                }
            }

            // Read and show each line from the file.
            string line = "";
            using (StreamReader sr = new StreamReader("CDriveDirs.txt"))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    Console.WriteLine(line);
                }
            }
        }
    }
}
Imports System.IO
Class Program

    Shared Sub Main()

        ' Get the directories currently on the C drive.
        Dim cDirs As DirectoryInfo() = New DirectoryInfo("c:\").GetDirectories()

        ' Write each directory name to a file.
        Using sw As StreamWriter = New StreamWriter("CDriveDirs.txt")
            For Each Dir As DirectoryInfo In cDirs
                sw.WriteLine(Dir.Name)
            Next
        End Using

        'Read and show each line from the file.
        Dim line As String = ""
        Using sr As StreamReader = New StreamReader("CDriveDirs.txt")
            Do
                line = sr.ReadLine()
                Console.WriteLine(line)
            Loop Until line Is Nothing
        End Using


    End Sub

End Class

備註

StreamWriter 專為特定編碼方式輸出字元,而類別衍生自Stream專為位元組輸入和輸出。is designed for character output in a particular encoding, whereas classes derived from Stream are designed for byte input and output.

重要

此類型會實作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.

StreamWriter 若要使用的執行個體的預設值UTF8Encoding除非另有指定。defaults to using an instance of UTF8Encoding unless specified otherwise. 這個執行個體UTF8Encoding因此建構沒有位元組順序標記 (BOM),其GetPreamble方法會傳回空的位元組陣列。This instance of UTF8Encoding is constructed without a byte order mark (BOM), so its GetPreamble method returns an empty byte array. 這個建構函式的預設 utf-8 編碼傳回例外狀況無效的位元組。The default UTF-8 encoding for this constructor throws an exception on invalid bytes. 此行為是編碼物件中所提供的行為不同Encoding.UTF8屬性。This behavior is different from the behavior provided by the encoding object in the Encoding.UTF8 property. 若要指定 BOM,並判斷是否要在無效的位元組上擲回例外狀況,使用 接受的編碼物件,做為參數,例如建構函式StreamWriter(String, Boolean, Encoding)StreamWriterTo specify a BOM and determine whether an exception is thrown on invalid bytes, use a constructor that accepts an encoding object as a parameter, such as StreamWriter(String, Boolean, Encoding) or StreamWriter.

根據預設,StreamWriter不是安全執行緒。By default, a StreamWriter is not thread safe. 請參閱TextWriter.Synchronized安全執行緒包裝函式。See TextWriter.Synchronized for a thread-safe wrapper.

如需一般 I/O 工作的清單,請參閱 < 一般 I/O 工作For a list of common I/O tasks, see Common I/O Tasks.

建構函式

StreamWriter(Stream) StreamWriter(Stream) StreamWriter(Stream) StreamWriter(Stream)

使用 UTF-8 編碼方式和預設緩衝區大小,為指定的資料流初始化 StreamWriter 類別的新執行個體。Initializes a new instance of the StreamWriter class for the specified stream by using UTF-8 encoding and the default buffer size.

StreamWriter(Stream, Encoding) StreamWriter(Stream, Encoding) StreamWriter(Stream, Encoding) StreamWriter(Stream, Encoding)

使用指定的編碼方式和預設緩衝區大小,為指定的資料流初始化 StreamWriter 類別的新執行個體。Initializes a new instance of the StreamWriter class for the specified stream by using the specified encoding and the default buffer size.

StreamWriter(Stream, Encoding, Int32) StreamWriter(Stream, Encoding, Int32) StreamWriter(Stream, Encoding, Int32) StreamWriter(Stream, Encoding, Int32)

使用指定的編碼方式和緩衝區大小,為指定的資料流初始化 StreamWriter 類別的新執行個體。Initializes a new instance of the StreamWriter class for the specified stream by using the specified encoding and buffer size.

StreamWriter(Stream, Encoding, Int32, Boolean) StreamWriter(Stream, Encoding, Int32, Boolean) StreamWriter(Stream, Encoding, Int32, Boolean) StreamWriter(Stream, Encoding, Int32, Boolean)

使用指定的編碼方式和緩衝區大小,為指定的資料流初始化 StreamWriter 類別的新執行個體,並選擇性讓資料流保持開啟。Initializes a new instance of the StreamWriter class for the specified stream by using the specified encoding and buffer size, and optionally leaves the stream open.

StreamWriter(String) StreamWriter(String) StreamWriter(String) StreamWriter(String)

使用預設編碼方式和緩衝區大小,為指定的檔案初始化 StreamWriter 類別的新執行個體。Initializes a new instance of the StreamWriter class for the specified file by using the default encoding and buffer size.

StreamWriter(String, Boolean) StreamWriter(String, Boolean) StreamWriter(String, Boolean) StreamWriter(String, Boolean)

使用預設編碼方式和緩衝區大小,為指定的檔案初始化 StreamWriter 類別的新執行個體。Initializes a new instance of the StreamWriter class for the specified file by using the default encoding and buffer size. 如果檔案存在,可以將它寫入或附加。If the file exists, it can be either overwritten or appended to. 如果檔案不存在,這個建構函式會建立新的檔案。If the file does not exist, this constructor creates a new file.

StreamWriter(String, Boolean, Encoding) StreamWriter(String, Boolean, Encoding) StreamWriter(String, Boolean, Encoding) StreamWriter(String, Boolean, Encoding)

使用指定的編碼方式和預設緩衝區大小,為指定的檔案初始化 StreamWriter 類別的新執行個體。Initializes a new instance of the StreamWriter class for the specified file by using the specified encoding and default buffer size. 如果檔案存在,可以將它寫入或附加。If the file exists, it can be either overwritten or appended to. 如果檔案不存在,這個建構函式會建立新的檔案。If the file does not exist, this constructor creates a new file.

StreamWriter(String, Boolean, Encoding, Int32) StreamWriter(String, Boolean, Encoding, Int32) StreamWriter(String, Boolean, Encoding, Int32) StreamWriter(String, Boolean, Encoding, Int32)

使用預設編碼方式和緩衝區大小,為指定路徑上的指定檔案初始化 StreamWriter 類別的新執行個體。Initializes a new instance of the StreamWriter class for the specified file on the specified path, using the specified encoding and buffer size. 如果檔案存在,可以將它寫入或附加。If the file exists, it can be either overwritten or appended to. 如果檔案不存在,這個建構函式會建立新的檔案。If the file does not exist, this constructor creates a new file.

欄位

CoreNewLine CoreNewLine CoreNewLine CoreNewLine

儲存這個 TextWriter 所使用的新行字元。Stores the newline characters used for this TextWriter.

(Inherited from TextWriter)
Null Null Null Null

提供 StreamWriter,但不包含可寫入但無法讀取的備份存放區。Provides a StreamWriter with no backing store that can be written to, but not read from.

屬性

AutoFlush AutoFlush AutoFlush AutoFlush

取得或設定值,指出 StreamWriter 在每次呼叫 Write(Char) 之後,是否要將其緩衝區清除到基礎資料流。Gets or sets a value indicating whether the StreamWriter will flush its buffer to the underlying stream after every call to Write(Char).

BaseStream BaseStream BaseStream BaseStream

取得以備份存放區作介面的基礎資料流。Gets the underlying stream that interfaces with a backing store.

Encoding Encoding Encoding Encoding

取得寫入輸出的 EncodingGets the Encoding in which the output is written.

FormatProvider FormatProvider FormatProvider FormatProvider

取得控制格式設定的物件。Gets an object that controls formatting.

(Inherited from TextWriter)
NewLine NewLine NewLine NewLine

取得或設定目前 TextWriter 所使用的行結束字元字串。Gets or sets the line terminator string used by the current TextWriter.

(Inherited from TextWriter)

方法

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

關閉目前的 StreamWriter 物件和基礎資料流。Closes the current StreamWriter object and the underlying stream.

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

釋放由 TextWriter 物件使用的所有資源。Releases all resources used by the TextWriter object.

(Inherited from TextWriter)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

使任何緩衝資料都寫入基礎資料流,釋放 StreamWriter 所使用的非受控資源,然後選擇性地釋放受控資源。Causes any buffered data to be written to the underlying stream, releases the unmanaged resources used by the StreamWriter, and optionally the managed resources.

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

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

在記憶體回收行程回收目前 StreamWriter 的資源前,先將它的資源釋放。Frees the resources of the current StreamWriter before it is reclaimed by the garbage collector.

Flush() Flush() Flush() Flush()

清除目前寫入器 (Writer) 的所有緩衝區,並且造成任何緩衝資料都寫入基礎資料流。Clears all buffers for the current writer and causes any buffered data to be written to the underlying stream.

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

以非同步的方式清除這個資料流的所有緩衝區,並造成任何緩衝資料都寫入基礎裝置。Clears all buffers for this stream asynchronously and causes any buffered data to be written to the underlying device.

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 的淺層複本 (Shallow Copy)。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)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)
Write(Boolean) Write(Boolean) Write(Boolean) Write(Boolean)

Boolean 值的文字表示寫入到文字字串或資料流。Writes the text representation of a Boolean value to the text string or stream.

(Inherited from TextWriter)
Write(Char) Write(Char) Write(Char) Write(Char)

將一個字元寫入資料流。Writes a character to the stream.

Write(Char[]) Write(Char[]) Write(Char[]) Write(Char[])

將字元陣列寫入資料流。Writes a character array to the stream.

Write(Char[], Int32, Int32) Write(Char[], Int32, Int32) Write(Char[], Int32, Int32) Write(Char[], Int32, Int32)

將字元子陣列寫入資料流。Writes a subarray of characters to the stream.

Write(Decimal) Write(Decimal) Write(Decimal) Write(Decimal)

將十進位值的文字表示寫入到文字字串或資料流。Writes the text representation of a decimal value to the text string or stream.

(Inherited from TextWriter)
Write(Double) Write(Double) Write(Double) Write(Double)

將 8 位元組浮點數值的文字表示寫入到文字字串或資料流。Writes the text representation of an 8-byte floating-point value to the text string or stream.

(Inherited from TextWriter)
Write(Int32) Write(Int32) Write(Int32) Write(Int32)

將 4 位元組帶正負號的整數之文字表示寫入到文字字串或資料流。Writes the text representation of a 4-byte signed integer to the text string or stream.

(Inherited from TextWriter)
Write(Int64) Write(Int64) Write(Int64) Write(Int64)

將 8 位元組帶正負號的整數之文字表示寫入到文字字串或資料流。Writes the text representation of an 8-byte signed integer to the text string or stream.

(Inherited from TextWriter)
Write(Object) Write(Object) Write(Object) Write(Object)

呼叫該物件的 ToString 方法,將物件的文字表示寫入至文字字串或資料流。Writes the text representation of an object to the text string or stream by calling the ToString method on that object.

(Inherited from TextWriter)
Write(ReadOnlySpan<Char>) Write(ReadOnlySpan<Char>) Write(ReadOnlySpan<Char>) Write(ReadOnlySpan<Char>)
Write(Single) Write(Single) Write(Single) Write(Single)

將 4 位元組浮點數值的文字表示寫入到文字字串或資料流。Writes the text representation of a 4-byte floating-point value to the text string or stream.

(Inherited from TextWriter)
Write(String) Write(String) Write(String) Write(String)

將字串寫入資料流。Writes a string to the stream.

Write(String, Object) Write(String, Object) Write(String, Object) Write(String, Object)

使用與 Format(String, Object) 方法相同的語意,將格式化字串寫入到文字字串或資料流。Writes a formatted string to the text string or stream, using the same semantics as the Format(String, Object) method.

(Inherited from TextWriter)
Write(String, Object, Object) Write(String, Object, Object) Write(String, Object, Object) Write(String, Object, Object)

使用與 Format(String, Object, Object) 方法相同的語意,將格式化字串寫入到文字字串或資料流。Writes a formatted string to the text string or stream, using the same semantics as the Format(String, Object, Object) method.

(Inherited from TextWriter)
Write(String, Object, Object, Object) Write(String, Object, Object, Object) Write(String, Object, Object, Object) Write(String, Object, Object, Object)

使用與 Format(String, Object, Object, Object) 方法相同的語意,將格式化字串寫入到文字字串或資料流。Writes a formatted string to the text string or stream, using the same semantics as the Format(String, Object, Object, Object) method.

(Inherited from TextWriter)
Write(String, Object[]) Write(String, Object[]) Write(String, Object[]) Write(String, Object[])

使用與 Format(String, Object[]) 方法相同的語意,將格式化字串寫入到文字字串或資料流。Writes a formatted string to the text string or stream, using the same semantics as the Format(String, Object[]) method.

(Inherited from TextWriter)
Write(StringBuilder) Write(StringBuilder) Write(StringBuilder) Write(StringBuilder) Inherited from TextWriter
Write(UInt32) Write(UInt32) Write(UInt32) Write(UInt32)

將 4 位元組不帶正負號的整數之文字表示寫入到文字字串或資料流。Writes the text representation of a 4-byte unsigned integer to the text string or stream.

(Inherited from TextWriter)
Write(UInt64) Write(UInt64) Write(UInt64) Write(UInt64)

將 8 位元組不帶正負號的整數之文字表示寫入到文字字串或資料流。Writes the text representation of an 8-byte unsigned integer to the text string or stream.

(Inherited from TextWriter)
WriteAsync(Char) WriteAsync(Char) WriteAsync(Char) WriteAsync(Char)

以非同步方式將字元寫入至資料流。Writes a character to the stream asynchronously.

WriteAsync(Char[]) WriteAsync(Char[]) WriteAsync(Char[]) WriteAsync(Char[])

以非同步方式將字元陣列寫入到文字字串或資料流。Writes a character array to the text string or stream asynchronously.

(Inherited from TextWriter)
WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32)

以非同步方式將字元的子陣列寫入至資料流。Writes a subarray of characters to the stream asynchronously.

WriteAsync(ReadOnlyMemory<Char>, CancellationToken) WriteAsync(ReadOnlyMemory<Char>, CancellationToken) WriteAsync(ReadOnlyMemory<Char>, CancellationToken) WriteAsync(ReadOnlyMemory<Char>, CancellationToken)
WriteAsync(String) WriteAsync(String) WriteAsync(String) WriteAsync(String)

以非同步方式將字串寫入至資料流。Writes a string to the stream asynchronously.

WriteAsync(StringBuilder, CancellationToken) WriteAsync(StringBuilder, CancellationToken) WriteAsync(StringBuilder, CancellationToken) WriteAsync(StringBuilder, CancellationToken) Inherited from TextWriter
WriteLine() WriteLine() WriteLine() WriteLine()

將行結束字元寫入到文字字串或資料流。Writes a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Boolean) WriteLine(Boolean) WriteLine(Boolean) WriteLine(Boolean)

Boolean 值的文字表示,並加上行結束字元寫入到文字字串或資料流。Writes the text representation of a Boolean value followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Char) WriteLine(Char) WriteLine(Char) WriteLine(Char)

將一個字元 (其後加上行結束字元) 寫入到文字字串或資料流。Writes a character followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Char[]) WriteLine(Char[]) WriteLine(Char[]) WriteLine(Char[])

將一個字元 (其後加上行結束字元) 寫入到文字字串或資料流。Writes an array of characters followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32) WriteLine(Char[], Int32, Int32)

將字元子陣列 (其後加上行結束字元) 寫入到文字字串或資料流。Writes a subarray of characters followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Decimal) WriteLine(Decimal) WriteLine(Decimal) WriteLine(Decimal)

將十進位值的文字表示加上行結束字元,寫入到文字字串或資料流。Writes the text representation of a decimal value followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Double) WriteLine(Double) WriteLine(Double) WriteLine(Double)

將 8 位元組浮點數值的文字表示加上行結束字元,寫入到文字字串或資料流。Writes the text representation of a 8-byte floating-point value followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Int32) WriteLine(Int32) WriteLine(Int32) WriteLine(Int32)

將 4 位元組帶正負號的整數之文字表示加上行結束字元,寫入到文字字串或資料流。Writes the text representation of a 4-byte signed integer followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Int64) WriteLine(Int64) WriteLine(Int64) WriteLine(Int64)

將 8 位元組帶正負號的整數之文字表示加上行結束字元,寫入到文字字串或資料流。Writes the text representation of an 8-byte signed integer followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(Object) WriteLine(Object) WriteLine(Object) WriteLine(Object)

透過呼叫該物件上的 ToString 方法,將該物件的文字表示加上行結束字元,寫入到文字字串或資料流。Writes the text representation of an object by calling the ToString method on that object, followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(ReadOnlySpan<Char>) WriteLine(ReadOnlySpan<Char>) WriteLine(ReadOnlySpan<Char>) WriteLine(ReadOnlySpan<Char>)
WriteLine(Single) WriteLine(Single) WriteLine(Single) WriteLine(Single)

將 4 位元組浮點數值的文字表示加上行結束字元,寫入到文字字串或資料流。Writes the text representation of a 4-byte floating-point value followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(String) WriteLine(String) WriteLine(String) WriteLine(String)
WriteLine(String, Object) WriteLine(String, Object) WriteLine(String, Object) WriteLine(String, Object)

使用與 Format(String, Object) 方法相同的語意,將格式化字串和新行寫入到文字字串或資料流。Writes a formatted string and a new line to the text string or stream, using the same semantics as the Format(String, Object) method.

(Inherited from TextWriter)
WriteLine(String, Object, Object) WriteLine(String, Object, Object) WriteLine(String, Object, Object) WriteLine(String, Object, Object)

使用與 Format(String, Object, Object) 方法相同的語意,將格式化字串和新行寫入到文字字串或資料流。Writes a formatted string and a new line to the text string or stream, using the same semantics as the Format(String, Object, Object) method.

(Inherited from TextWriter)
WriteLine(String, Object, Object, Object) WriteLine(String, Object, Object, Object) WriteLine(String, Object, Object, Object) WriteLine(String, Object, Object, Object)

使用與 Format(String, Object) 相同的語意,寫出格式化字串和新行。Writes out a formatted string and a new line, using the same semantics as Format(String, Object).

(Inherited from TextWriter)
WriteLine(String, Object[]) WriteLine(String, Object[]) WriteLine(String, Object[]) WriteLine(String, Object[])

使用與 Format(String, Object) 相同的語意,寫出格式化字串和新行。Writes out a formatted string and a new line, using the same semantics as Format(String, Object).

(Inherited from TextWriter)
WriteLine(StringBuilder) WriteLine(StringBuilder) WriteLine(StringBuilder) WriteLine(StringBuilder) Inherited from TextWriter
WriteLine(UInt32) WriteLine(UInt32) WriteLine(UInt32) WriteLine(UInt32)

將 4 位元組不帶正負號的整數之文字表示加上行結束字元,寫入到文字字串或資料流。Writes the text representation of a 4-byte unsigned integer followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLine(UInt64) WriteLine(UInt64) WriteLine(UInt64) WriteLine(UInt64)

將 8 位元組不帶正負號的整數之文字表示加上行結束字元,寫入到文字字串或資料流。Writes the text representation of an 8-byte unsigned integer followed by a line terminator to the text string or stream.

(Inherited from TextWriter)
WriteLineAsync() WriteLineAsync() WriteLineAsync() WriteLineAsync()

將行結束字元以非同步方式寫入至資料流。Writes a line terminator asynchronously to the stream.

WriteLineAsync(Char) WriteLineAsync(Char) WriteLineAsync(Char) WriteLineAsync(Char)

以非同步方式將一個字元 (其後加上行結束字元) 寫入到資料流。Writes a character followed by a line terminator asynchronously to the stream.

WriteLineAsync(Char[]) WriteLineAsync(Char[]) WriteLineAsync(Char[]) WriteLineAsync(Char[])

以非同步方式將字元子陣列 (其後加上行結束字元) 寫入到文字字串或資料流。Writes an array of characters followed by a line terminator asynchronously to the text string or stream.

(Inherited from TextWriter)
WriteLineAsync(Char[], Int32, Int32) WriteLineAsync(Char[], Int32, Int32) WriteLineAsync(Char[], Int32, Int32) WriteLineAsync(Char[], Int32, Int32)

以非同步方式將字元子陣列 (其後加上行結束字元) 寫入到資料流。Writes a subarray of characters followed by a line terminator asynchronously to the stream.

WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken) WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken) WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken) WriteLineAsync(ReadOnlyMemory<Char>, CancellationToken)
WriteLineAsync(String) WriteLineAsync(String) WriteLineAsync(String) WriteLineAsync(String)

以非同步方式將字串 (後面接著行結束字元) 寫入至資料流。Writes a string followed by a line terminator asynchronously to the stream.

WriteLineAsync(StringBuilder, CancellationToken) WriteLineAsync(StringBuilder, CancellationToken) WriteLineAsync(StringBuilder, CancellationToken) WriteLineAsync(StringBuilder, CancellationToken) Inherited from TextWriter

明確介面實作

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

如需這個成員的說明,請參閱 Dispose()For a description of this member, see Dispose().

(Inherited from TextWriter)

適用於

另請參閱