将日志写入txt文件中
Sub 将信息写入日志中(日志内容)
'判断日志文件夹是否存在,不存在就创建
If Not Directory.Exists(Application.StartupPath & "\log") Then
Directory.CreateDirectory(Application.StartupPath & "\log")
End If
'新建一个以当前时间命名的日志文件,精确到秒
Dim logFilePath As String = Application.StartupPath & "\log\" & DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") & ".txt"
'将指定内容写入日志文件
Using sw As StreamWriter = File.AppendText(logFilePath)
sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") & " " & 日志内容)
End Using
End Sub

浙公网安备 33010602011771号