您的位置:首页 > 其它

Write log file with .net

2011-07-13 08:37 375 查看
If you need to moniter DLL file which dont run and must been called by another application or solution, at this time i believe it is neccessary to write log file. Pls. reference this codes as below:
Private Sub WriteLog(ByVal strCurText As String)
Dim strFilePath As String = "C:\Log.txt"

Dim strOldText As String = File.ReadAllText(strFilePath, System.Text.Encoding.Default)
File.WriteAllText(strFilePath, DateTime.Now.ToString() + " " + strCurText + System.Environment.NewLine, System.Text.Encoding.Default)
File.AppendAllText(strFilePath, strOldText, System.Text.Encoding.Default)
End Sub

The latest log record(s) will be appended the top.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐