TextFieldParser.ReadToEnd 方法

定義

讀取文字檔的其餘部分,並將其以字串傳回。

public:
 System::String ^ ReadToEnd();
public string? ReadToEnd ();
public string ReadToEnd ();
member this.ReadToEnd : unit -> string
Public Function ReadToEnd () As String

傳回

取自檔案或資料流的其餘文字。

範例

這個範例會 ReadToEnd 使用 方法來讀取整個檔案 ParserText.txt ,並將它寫入檔案 Testfile.txt

Using FileReader As New Microsoft.VisualBasic.FileIO.
    TextFieldParser("C:\ParserText.txt")

    Dim allText As String = FileReader.ReadToEnd
    My.Computer.FileSystem.WriteAllText("C://testfile.txt", allText, True)
End Using

如果 Testfile.txt 不存在,則由 WriteAllText 方法建立。

備註

這是進階成員;除非您按兩下 [ 所有 ] 索引標籤,否則不會顯示在IntelliSense 中。

如果因為已到達檔案的結尾而沒有其他內容可讀取, Nothing 則會傳回 。

方法 ReadToEnd 不會忽略空白行和批注。

適用於

另請參閱