0

これらのリーダーを複数作成したいのですが、私のプログラムは最初のファイルストリームしか読み取りません。すべてを読み取る方法はありますか? または、それらを別のボタンに配置する必要がありますか? ここに私の現在のコードがあります:

Public aRecp As String()
Public listRecp As New List(Of String)
Public aEmail As String()
Public listEmail As New List(Of String)
Public aName As String()
Public listName As New List(Of String)
Public sArray As String()
Public sList As New List(Of String)

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

    Dim fStream As New System.IO.FileStream("messages.txt", IO.FileMode.Open)
    Dim sReader As New System.IO.StreamReader(fStream)
    Dim Index As Integer = 0
    Do While sReader.Peek >= 0
        sList.Add(sReader.ReadLine)
    Loop
    sArray = sList.ToArray
    fStream.Close()
    sReader.Close()

    Dim StreamName As New System.IO.FileStream("sendername.txt", IO.FileMode.Open)
    Dim ReaderName As New System.IO.StreamReader(StreamName)
    Dim IndexName As Integer = 0
    Do While ReaderName.Peek >= 0
        listName.Add(sReader.ReadLine)
    Loop
    aName = listName.ToArray
    StreamName.Close()
    ReaderName.Close()

    Dim StreamEmail As New System.IO.FileStream("senderemail.txt", IO.FileMode.Open)
    Dim ReaderEmail As New System.IO.StreamReader(StreamEmail)
    Dim IndexEmail As Integer = 0
    Do While ReaderEmail.Peek >= 0
        listEmail.Add(sReader.ReadLine)
    Loop
    aEmail = listEmail.ToArray
    StreamEmail.Close()
    ReaderEmail.Close()

    Dim StreamRecp As New System.IO.FileStream("recpname.txt", IO.FileMode.Open)
    Dim ReaderRecp As New System.IO.StreamReader(StreamRecp)
    Dim IndexRecp As Integer = 0
    Do While ReaderRecp.Peek >= 0
        listRecp.Add(ReaderRecp.ReadLine)
    Loop
    aRecp = listRecp.ToArray
    StreamRecp.Close()
    ReaderRecp.Close()

サブ終了

4

1 に答える 1