您好,登錄后才能下訂單哦!
小編給大家分享一下VB.NET怎么寫Log方法,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
最近在項目中有用到VB.NET寫Log方法的功能.具體代碼如下:
Code
Public Sub WriteLog()Sub
WriteLog(ByVal Msg As String)
Dim varAppPath As String
varAppPath = System.AppDomain.
CurrentDomain.SetupInformation.
ApplicationBase + "log"
System.IO.Directory.CreateDirectory
(varAppPath)
Dim head As String
head = System.DateTime.Now.Hour.
ToString() + ":" + System.DateTime.
Now.Minute.ToString()
headhead = head + ":" + System.DateTime.
Now.Second.ToString() + ":" +
System.DateTime.Now.Millisecond.ToString()
Msg = head + System.Environment.
NewLine + Msg + System.Environment.NewLine
Dim strDate As String
strDate = System.DateTime.Now.
ToString("yyyyMMdd")
Dim strFile As String
strFile = varAppPath + "\" +
strDate + ".log"
Dim SW As System.IO.StreamWriter
SW = New System.IO.StreamWriter
(strFile, True)
SW.WriteLine(Msg)
SW.Flush()
SW.Close()
End Sub
以上是“VB.NET怎么寫Log方法”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。