MSCL超级工具类(C#),开发人员必备,开发利器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MSCL超级工具类(C#),开发人员必备,开发利器相关的知识,希望对你有一定的参考价值。

MSCL超强工具类库

是基于C#开发的超强工具类集合,涵盖了日常B/S或C/S开发的诸多方面,包含上百个常用封装类(数据库操作类全面支持mysql、Access、Oracle、Sqlserver、Sqlite等数据库,常用字符串处理类,内存容器类,Session/Cookie/Cache类,Config配置文件帮助类,数据类型转换类,进制转换类,时间日期帮助类,数据加密解密类,文件/目录操作类,文件下载类,FTP操作类,图片上传/下载类,图片常用处理类-翻转,模糊,水印,缩略等,Json辅助类,Log日志类,Http封装类,Email邮件封装类,NOPI操作类-无依赖Office组件实现execl导入导出利器,Execl/CSV操作类,Until常用工具类,数据分页类,远程采集类,JS封装类,Reg正则验证类,Request请求类,随机数生成类,序列化反序列化封装类,XML操作类,ZIP压缩和解压类等等等。。。此处省略一万字),即拿即用,封装类附带调用示例和参数注释,全傻瓜式调用,简单易用。拥有此超强工具类,能大大的提高C#开发人员的效率和代码质量,真正做到“工具在手,一有尽有”,让苦逼的广大程序猿朋友,早日脱离苦海,畅游在代码的世界里 ^_^,如需购买MSCL超级工具类库源码,请扫码博客右侧二维码购买

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
using System.Data;
using System.Data.SqlClient;
using System.Web;
 
namespace MSCL
{
    /// <summary>
    /// 日志帮助类
    /// </summary>
    public class LogHelper
    {
 
        /// <summary>
        /// 记录错误信息
        /// </summary>
        /// <param name="ex">错误</param>
        public static void ErrorLog(Exception ex)
        {
            string dir = Path() + @"/Log/" + DateTime.Now.ToString("yyyy-MM") + "/";
            string fileName = "log_" + DateTime.Now.ToString("dd") + ".txt";
            string path = dir + fileName;
            StreamWriter sw = null;
            try
            {
                Directory.CreateDirectory(dir);
                sw = new StreamWriter(path, true);
                sw.WriteLine(string.Format("-------------{0}--------------", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ffff")));
                sw.WriteLine(ex.ToString());
                sw.WriteLine();
                sw.Flush();
            }
            catch { }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                    sw = null;
                }
            }
        }
 
        /// <summary>
        /// 记录错误信息
        /// </summary>
        /// <param name="str">错误信息</param>
        public static void ErrorLog(string str)
        {
            string dir = Path() + @"/Log/" + DateTime.Now.ToString("yyyy-MM") + "/";
            string fileName = "log_custome_" + DateTime.Now.ToString("dd") + ".txt";
            string path = dir + fileName;
            StreamWriter sw = null;
            try
            {
                Directory.CreateDirectory(dir);
                sw = new StreamWriter(path, true);
                sw.WriteLine(string.Format("-------------{0}--------------", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ffff")));
                sw.WriteLine(str);
                sw.WriteLine();
                sw.Flush();
            }
            catch { }
            finally
            {
                if (sw != null)
                {
                    sw.Close();
                    sw = null;
                }
            }
        }
 
        /// <summary>
        /// 拿到项目所在目录
        /// </summary>
        /// <returns></returns>
        private static string Path()
        {
            string path = HttpContext.Current.Server.MapPath("~/");
            return path;
        }
    }
}

技术分享

技术分享

技术分享

以上是关于MSCL超级工具类(C#),开发人员必备,开发利器的主要内容,如果未能解决你的问题,请参考以下文章

推荐开发人员必备的强兵利器

程序员必备开发工具,提高开发效率的神兵利器,大多都是免费的哦

适合前端开发者的一些超级实用小工具及网站合集

适合前端开发者的一些超级实用小工具及网站合集

C#基础总结 —— C#开发工具 Visual Studio(IDE)

python程序员开发必备工具,你用过几个?