问题描述
- vb.net如何读取文件,把文件数据保存成数组?
-
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Me.ListBox1.Items.Clear() Dim StrRed As StreamReader = New StreamReader("C:JD.JD", System.Text.Encoding.Default) While Not StrRed.EndOfStream Me.ListBox1.Items.Add(StrRed.ReadLine()) End While StrRed.Dispose()
我编的这个只是在listbox中显示了文件里面数据,并没有存成数组,请问该如何修改呢?
解决方案
Dim arr() As String = File.ReadAllLines("c:jd.jd")
时间: 2024-10-30 05:05:28