본문 바로가기
Programing/vb.net

비쥬얼베이직(비주얼베이직)visual basic,vb.net 강좌-텍스트 읽고 쓰기,StreamReader,FileReader ,ReadToEnd

by 고니의 경제주식 2017. 1. 16.
반응형



Public Class Form1


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

        Dim FileReader As StreamReader

        Dim results As DialogResult

        results = OpenFileDialog1.ShowDialog


        If results = Windows.Forms.DialogResult.OK Then

            FileReader = New StreamReader(OpenFileDialog1.FileName)

            TextBox1.Text = FileReader.ReadToEnd()

            FileReader.Close()


        End If


    End Sub


    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim FileWriter As StreamWriter

        Dim results As DialogResult

        results = SaveFileDialog1.ShowDialog


        If results = DialogResult.OK Then


            FileWriter = New StreamWriter(SaveFileDialog1.FileName, False)

            FileWriter.Write(TextBox1.Text)

            FileWriter.Close()



        End If

    End Sub

End Class


반응형