日志

Public Shared Sub WriteLog(ByVal strStyle As String, ByVal strContent As String)
  Dim curDate As String = CDate(Now).ToString("yyyy-MM-dd HH:mm:ss")
  Dim path As String = GetPath() & "\log"
  If Not My.Computer.FileSystem.DirectoryExists(path) Then
  My.Computer.FileSystem.CreateDirectory(path)
  End If
  path &= "\" & CDate(curDate).ToString("yyyyMMdd") & ".txt"
  If Not My.Computer.FileSystem.FileExists(path) Then
  My.Computer.FileSystem.WriteAllText(path, String.Empty, False)
  End If

  Dim strValue As String = String.Empty
  strValue = "---" & curDate & "---" & vbCrLf
  strValue &= "---操作类型[" & strStyle & "]---" & vbCrLf
  strValue &= "---错误原因---" & vbCrLf
  strValue &= strContent & vbCrLf & vbCrLf & vbCrLf
  My.Computer.FileSystem.WriteAllText(path, strValue, True)
End Sub

posted @ 2020-01-15 14:41  revgin  阅读(101)  评论(0)    收藏  举报