TextFieldParser.ReadToEnd 方法

定義

讀取剩餘的文字檔,並以字串形式回傳。

public:
 System::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 方法不會忽略空白行與註解。

適用於

另請參閱