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...
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...