⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logger.cs

📁 不错的一个做的医院管理系统源码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Youzi.DBUtility
{
    public class Logger
    {
        
        
        public Logger()
        {
            StreamWriter sw = null;
            try
            {
                string d = DateTime.Now.ToString("yyyy年MM月dd日");
                string path = Application.StartupPath;
                if (File.Exists(path + "\\" + d + ".log"))
                {
                    sw = new StreamWriter(path + "\\" + d + ".log"); 
                       
                }
                else
                {
                    sw = File.CreateText(path + "\\" + d + ".log");
                }
            }
            catch (SqlException ex)
            {

                Console.WriteLine(ex.Message);
            }
            sw.Close();
        }

        public void log(String message)
        {
            StreamWriter sw = null;
            try
            {
                string d = DateTime.Now.ToString("yyyy年MM月dd日 hh:mm:ss");
                sw.WriteLine(d + ":" + message);
                sw.Flush();
            }
            catch (SqlException ex)
            {

                 Console.WriteLine(ex.Message);
            }
            sw.Close();
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -