Read a file line by line with VB.NET

前端 未结 2 1405
感动是毒
感动是毒 2021-01-02 03:54

The following code is used to read a file line by line.

It\'s just a very early version, so all I want to do is display the string in the immediate window. It\'s wor

相关标签:
2条回答
  • 2021-01-02 04:44

    Replaced the reader declaration with this one and now it works!

    Dim reader As New StreamReader(filetoimport.Text, Encoding.Default)
    

    Encoding.Default represents the ANSI code page that is set under Windows Control Panel.

    0 讨论(0)
  • 2021-01-02 04:49

    Like this... I used it to read Chinese characters...

    Dim reader as StreamReader = My.Computer.FileSystem.OpenTextFileReader(filetoimport.Text)
    Dim a as String
    
    Do
       a = reader.ReadLine
       '
       ' Code here
       '
    Loop Until a Is Nothing
    
    reader.Close()
    
    0 讨论(0)
提交回复
热议问题