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.
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.
相关文章推荐
- Read/Write App.Config File with .NET 2.0
- Read/Write App.Config File with .NET 2.0
- 【每日一摩斯】-LGWR Is Generating Trace file with "Warning: Log Write Time 540ms, Size 5444kb" In 10.2.0.4
- LGWR Is Generating Trace file with 'Warning Log Write Time 540ms, Size 5444kb' In 10.2.0.4 Database
- LGWR Is Generating Trace file with 'Warning Log Write Time 540ms, Size 5444kb' In 10.2.0.4 Database
- log file sync(日志文件同步) 与 Log file parallel write 等待事件(2)
- Write Auto-Updating Apps with .NET and the Background Intelligent Transfer Service API
- Compiler Error Message: CS0016: Could not write to output file 'c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\xxx' -- 'Access is denied. '
- try, i want to write log file of my programming jornney!
- 关于CS0016: Could not write to output file ‘c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files… ‘Access is denied.’ 的解决办法
- Oracle之 等待事件log file sync + log file parallel write (awr优化)
- How to mount partition with ntfs file system and read write access
- Create, Read, Write, Copy, Move and Delete a Text File using C# and VB.NET
- How to mount partition with ntfs file system and read write access
- Could not write to output file 'c:\WINDOWS\Microsoft.NET\Framework\..dll-拒绝访问
- 关于CS0016: Could not write to output file ‘c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files… ‘Access is denied.’ 的解决办法
- 解决:Could not write to output file 'c:\windows\Microsoft.NET\Framework\........dll' -- '拒绝访问。 '
- Oracle之 等待事件log file sync + log file parallel write (awr优化)
- Write Auto-Updating Apps with .NET and the Background Intelligent Transfer Service API
- log file sync, log file parallell write