Re: VB .Net query (Visual Studio 2017 version 15.7.5)

  • Thread starter Thread starter hm_2018
  • Start date Start date
H

hm_2018

Guest
Dear All

I am sorry to ask, but would be so grateful for your help please? I am trying to check whether a text file that has been written to disc, using Visual Studio 2017, has had data written to it. When I open the text file, to check the contents of the Notepad text file, it is empty. The names.txt file is on my Windows 10 hard drive.

Please could you advise and kindly see below?

Thank you.

Best wishes

Script

Imports System.IO

Public Class Form1

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

Dim names As String() = New String() {"Person 1", "Person 2", "Person 3", "Person"}

Dim s As String Using sw As StreamWriter = New StreamWriter("C:\Users\user\source\repos\WindowsApp - Examples\WindowsApp5\names.txt")

For Each s In names

sw.WriteLine(s)

Next s

sw.Close()

End Using

' Read and show each line from the file.

Dim line As String

Using sr As StreamReader = New StreamReader("C:\Users\user\source\repos\WindowsApp - Examples\WindowsApp5\names.txt")

line = sr.ReadLine()

While (line <> Nothing)

MessageBox.Show(line)

line = sr.ReadLine()

End While sr.Close()

End Using

End Sub

End Class

Continue reading...
 

Similar threads

R
Replies
0
Views
176
Ravi Kumar12233
R
I
Replies
0
Views
158
Innovators World Wide
I
Back
Top