Public i As Integer = 0
Private Sub btnaceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaceptar.Click
Dim filename As String = Directory.GetCurrentDirectory & "\log.txt"
Dim tempfile As String = Path.GetTempFileName()
i += 1
Using writer = New StreamWriter(tempfile)
Using reader = New StreamReader(filename)
writer.WriteLine(Now.ToString("dd-MM-yyyy HH:mm:ss:ffff") & "|" & tbinsertar.Text.Trim & "|" & i)
While Not reader.EndOfStream
writer.WriteLine(reader.ReadLine())
End While
End Using
End Using
File.Copy(tempfile, filename, True)
File.Delete(tempfile)
End Sub
fuente: https://stackoverflow.com/questions/2401523/how-to-insert-row-in-first-line-of-text-file
No hay comentarios.:
Publicar un comentario