need help!? read and write (txt)

Posts 1–6 of 6 · Page 1 of 1
need help!? read and write (txt)
hi i have a litte problem xD

i like to write something in a txt file.. for read i have this code:
Code:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Linie() As String = IO.File.ReadAllLines("C:\lol.txt")

        TextBox1.Text = Linie(0) & vbNewLine
        TextBox2.Text = Linie(1) & vbNewLine
   
    End Sub
End Class
someone know the code for write? can someone show me please!?
Code:
            
Dim oWrite As New System.IO.StreamWriter(".\serial.txt")
oWrite.WriteLine("pizzaman")
oWrite.Flush()
oWrite.Close()
there ya go
Not his code though.
Always use "using" if you can, it's much cleaner.

[php]
Using sWrite As New IO.StreamWriter(C:\Example\Here.txt")

sWrite.WriteLine(TextBox1.Text)
sWrite.WriteLine(TextBox2.Text)

End Using
[/php]
Ok thx i will try
Using sWrite As New IO.StreamWriter(C:\Example\Here.txt", append as boolean)


End Using

[php]Using sWrite As New IO.StreamWriter(C:\Example\Here.txt",true) 'this will APPEND the text

end using[/php]

[php]Using sWrite As New IO.StreamWriter(C:\Example\Here.txt") 'this is just going to overwrite it, why not ,false? Because it is false by default.

end using[/php]

[php]Using sWrite As New IO.StreamWriter(C:\Example\Here.txt")

for each line as string in listbox1.items
sWrite.write(line & vbnewline)
next[/php]

[php]
dim line as string
Using sRead As New IO.StreamReader(C:\Example\Here.txt")
while not sRead.EndOfStream
line = sRead.Readline
if line <> "" then
listbox1.items.add(line)
end if
end while
end using[/php]
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us