Can someone help to to understand how to write a student's name and final grade to a sequential file. I am doing this in Visual Basics. I see the syntax for write and read, but is not understanding how to use it in coding.
The answer depends on whether you are replacing what's in the file (or even if there is already a file) or adding to an already existing file. The easiest methods involve reading or writing all of the lines at once. For example, to read all lines of a text file into a string array you can do
Dim lines() As String = System.IO.File.ReadAllLines(filename)
My file did not exist, so i took the snippets that you gave to create the file. What i am trying to do is to write a student's name and final grade into a new file. But there are errors. Here is what I did so far:
Dim sw As New StreamWriter("C:\StudentMarks.txt", True)