Share via


TextFieldParser.ReadLine 메서드

정의

현재 줄을 문자열로 반환하고 커서를 다음 줄로 이동합니다.

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

반환

파일 또는 스트림의 현재 줄입니다.

예제

이 예제에서는 파일을 ParserText.txt 읽고 에 씁니다 Testfile.txt.

Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\ParserText.txt")
    MyReader.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited
    MyReader.Delimiters = New String() {","}
    Dim currentRow As String
    While Not MyReader.EndOfData
        Try
            currentRow = MyReader.ReadLine()
            My.Computer.FileSystem.WriteAllText(
               "C://testfile.txt", currentRow, True)
        Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
            MsgBox("Line " & ex.Message & " is invalid.  Skipping")
        End Try
    End While
End Using

가 없으면 Testfile.txt 메서드에 WriteAllText 의해 만들어집니다.

이 예제에서는 필드를 단일 문자열로 씁니다. 각 줄이 대상 파일 VbCrLf 의 자체 줄에 표시되도록 하려면 각 줄의 끝에 문자를 추가해야 합니다.

설명

메서드는 ReadLine 구문 분석을 수행하지 않습니다. 구분된 필드 내의 줄 끝 문자는 줄의 실제 끝으로 해석됩니다.

Nothing 는 파일의 끝에 도달하면 반환됩니다.

적용 대상

추가 정보