Also, I'm using VB. This is because I started a project a while ago. I didn't know C# at the time, so I am continuing the project using VB. (I'm sure I can figure it out if C# is used though.)
This is the app I made for this:

PROBLEM:
I will add this code to the button1.click event. (Button1 = Write)
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Setting the File up
If My.Computer.FileSystem.FileExists("C:\WriteFile.txt") = False Then
MessageBox.Show("You Dumbass, make a text file called ''WriteFile'' in your C:\ Directory! >_<")
Else
End If
' Open a file for writing
Dim FILENAME As String = ("C:\WriteFile.txt")
' Create a new StreamWriter as nsr
Dim nsr As StreamWriter
nsr = File.AppendText(FILENAME)
'Write the contents of textbox1 to a new line.
nsr.WriteLine(TextBox1.Text)
' Close the stream
nsr.Close()
End Sub

It writes!
Now lets get it to read.
I put this code into the button2.click event:
Code: Select all
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Creating a StreamRead
Dim nsr As New StreamReader("C:\WriteFile.txt")
'Simplifying the text
Dim txt As String = nsr.ReadToEnd()
'Adding the text to textbox2
TextBox2.text = txt
'Closing the Stream Reader
nsr.Close()
End Sub

It works, But lets say I want to put each line as a seperate Object in a combobox. So I replace textbox2 with combobox1.
I changed the code around to try to get it to read correctly.
Code: Select all
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Creating a StreamRead
Dim nsr As New StreamReader("C:\WriteFile.txt")
'Simplifying the text
Dim txt As String = nsr.ReadToEnd()
'Adding the text to textbox2
TextBox2.Items.Clear()
TextBox2.Items.Add(txt)
'Closing the Stream Reader
nsr.Close()
End Sub

SOLUTION CODE:
Code: Select all
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Creating a StreamRead
Dim nsr As New StreamReader("C:\WriteFile.txt")
'Adding Items to the Combobox
Do Until nsr.EndOfStream
Me.TextBox2.Items.Add(nsr.ReadLine)
Loop
'Closing the StreamReader
nsr.Close()
End Sub

Anyone can use this now... Don't delete this topic.
-Click