File.ReadLines ファイルの行を読み取ります
第一引数はパス
構文
File.File.ReadLines(パス)
戻り値は
Type: System.Collections.Generic.IEnumerable(Of String)
ファイルのすべての行、またはクエリの結果の行。
Type: System.Collections.Generic.IEnumerable(Of String)
ファイルのすべての行、またはクエリの結果の行。
サンプルソース
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim data As IEnumerable(Of String) = File.ReadLines(“C:\Users\user\Desktop\hoge33.txt”)
For Each s In data
TextBox1.Text += s
TextBox1.Text += Chr(13) & Chr(10)
Next
End Sub
End Class
実行結果は
テキストボックスに読み込んだファイルの内容が表示されます。
第二引数を指定してエンコードを指令することもできます。