Hi,
I have following code to write to a file. Normally with w.BaseStream.Seek(0, SeekOrigin.End), it should go to the end of the page and then begin writing. But it doesn't. It just overwrites everything ? How is this possible ??
Dim fs As New System.IO.FileStream("Stock Geheugensticks.doc", FileMode.Create, FileAccess.Write)
Dim w As New StreamWriter(fs)
w.BaseStream.Seek(0, SeekOrigin.End)
w.WriteLine(Date.Today & " " & FormatDateTime(Now, DateFormat.ShortTime))
w.WriteLine("Naam:")
w.WriteLine(cmb_geheugenstick.Text)
w.WriteLine("In stock:")
w.WriteLine(lbl_in_stock_geheugenstick.Text)
w.WriteLine("Uit stock:")
w.WriteLine(lbl_uit_stock_geheugenstick.Text)
w.WriteLine("Totaal:")
w.WriteLine(lbl_totaal_stock_geheugenstick.Text)
w.WriteLine("Aan gebruiker:")
w.WriteLine(cmb_gebruiker.Text)
w.Flush()
w.Close()
MessageBox.Show("Transfer succesvol uitgevoerd", "Transfer")
I have following code to write to a file. Normally with w.BaseStream.Seek(0, SeekOrigin.End), it should go to the end of the page and then begin writing. But it doesn't. It just overwrites everything ? How is this possible ??
Dim fs As New System.IO.FileStream("Stock Geheugensticks.doc", FileMode.Create, FileAccess.Write)
Dim w As New StreamWriter(fs)
w.BaseStream.Seek(0, SeekOrigin.End)
w.WriteLine(Date.Today & " " & FormatDateTime(Now, DateFormat.ShortTime))
w.WriteLine("Naam:")
w.WriteLine(cmb_geheugenstick.Text)
w.WriteLine("In stock:")
w.WriteLine(lbl_in_stock_geheugenstick.Text)
w.WriteLine("Uit stock:")
w.WriteLine(lbl_uit_stock_geheugenstick.Text)
w.WriteLine("Totaal:")
w.WriteLine(lbl_totaal_stock_geheugenstick.Text)
w.WriteLine("Aan gebruiker:")
w.WriteLine(cmb_gebruiker.Text)
w.Flush()
w.Close()
MessageBox.Show("Transfer succesvol uitgevoerd", "Transfer")