there ya goCode:Dim oWrite As New System.IO.StreamWriter(".\serial.txt") oWrite.WriteLine("pizzaman") oWrite.Flush() oWrite.Close()
hi i have a litte problem xD
i like to write something in a txt file.. for read i have this code:
someone know the code for write? can someone show me please!?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
there ya goCode:Dim oWrite As New System.IO.StreamWriter(".\serial.txt") oWrite.WriteLine("pizzaman") oWrite.Flush() oWrite.Close()
GER-Domi. (09-10-2010)
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]
TROLOLOLOLO
GER-Domi. (09-10-2010)
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]