• 写入日志小技巧


     EventLog log = new EventLog("Wodongni.Com");
                //  首先应判断日志来源是否存在,一个日志来源只能同时与一个事件绑定s
                if (!EventLog.SourceExists("New Application1"))
                    EventLog.CreateEventSource("New Application1""Wodongni.Com");
                try
                {
                    log.Source = "New Applications1";
                    log.WriteEntry("处理信息1", EventLogEntryType.Information);
                    log.WriteEntry("处理信息2", EventLogEntryType.Information);
                    throw new System.IO.FileNotFoundException("readme.txt文件未找到");
                }
                catch (System.IO.FileNotFoundException exception)
                {
                    log.WriteEntry(exception.Message, EventLogEntryType.Error);
                }
            private static void WriteMsg(string msg)
            {
                string txtPath = System.AppDomain.CurrentDomain.BaseDirectory+"\\demo.txt";
                StreamWriter sw = new StreamWriter(txtPath, true, System.Text.Encoding.Default);
                 sw.WriteLine("time:"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                sw.WriteLine(msg);
                sw.Close();
            }

    http://www.cnblogs.com/nokiaguy/archive/2009/02/26/1398708.html

  • 相关阅读:
    瑞游天翼客户端win7,win8,win10
    js循环POST提交添加辅助单位
    服务器状态检测(1)
    快速切换天财商龙门店后台.VB6.0
    大批量删除农行点菜宝菜品品相和房间
    社会工程学
    你还会记得吗
    优酷爆个人数据漏洞
    win8删除无线网络其中的一项配置
    穿越火线修改成宽屏模式
  • 原文地址:https://www.cnblogs.com/rhythmK/p/2491572.html
Copyright © 2020-2023  润新知