VB.NET写Log方法详细介绍
如果我们想使用VB.NET进行代码编写的话,首先就要从基本概念开始了解,然后通过不断的实践练习来积累一定的运用经验,才能很好的通过这款语言来实现我们需要的各种需求。下面就先来了解一下有关VB.NET写Log方法的相关操作。#t#

创新互联公司主营奎文网站建设的网络公司,主营网站建设方案,成都app开发,奎文h5微信小程序开发搭建,奎文网站营销推广欢迎奎文等地区企业咨询
最近在项目中有用到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方法相关代码编写方法就为大家介绍到这里。
分享文章:VB.NET写Log方法详细介绍
本文地址:http://jxruijie.cn/article/cccejco.html

 
                