VB.NET Log File


/ Published in: VB.NET
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Sub Log(ByVal txt As String)
  2. 'Open a file for writing
  3. Dim FILENAME As String = Server.MapPath("Log.txt")
  4.  
  5. 'Get a StreamReader class that can be used to read the file
  6. Dim objStreamWriter As StreamWriter
  7.  
  8. objStreamWriter = File.AppendText(FILENAME)
  9.  
  10. objStreamWriter.WriteLine(DateTime.Now.ToString() + " >> " + txt)
  11.  
  12. 'Close the stream
  13. objStreamWriter.Close()
  14. End Sub

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.