码迷,mamicode.com
首页 > 其他好文 > 详细

简单的log

时间:2015-01-23 16:02:33      阅读:205      评论:0      收藏:0      [点我收藏+]

标签:

简单的方法想日志中追加内容

public static void updateSql(string Name,string str)
        {
            FileStream fs = new FileStream(@"D:\Acer\logSql.txt", FileMode.Append);
            StreamWriter sw = new StreamWriter(fs,Encoding.UTF8);
            //开始写入
            sw.Write("\r\n\n" +Name +"文件\r\n" + str + "\r\n");
            //清空缓冲区
            sw.Flush();
            //关闭流
            sw.Close();
            fs.Close();
        }
        public static void updateNumberOfColumns(string Name, string str)
        {
            FileStream fs = new FileStream(@"D:\Acer\logColumns.txt", FileMode.Append);
            StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
            //开始写入
            sw.Write("\r\n\n" + Name + "文件\r\n数据:" + str + " 列数不正确\r\n");
            //清空缓冲区
            sw.Flush();
            //关闭流
            sw.Close();
            fs.Close();
        }
        public static void updateInventory(string name, string str)
        {
            FileStream fs = new FileStream(@"D:\Acer\PAP_Inventory.txt", FileMode.Append);
            StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
            //开始写入
            sw.Write("\r\n\n"+name+"---" + str+"----");
            //清空缓冲区
            sw.Flush();
            //关闭流
            sw.Close();
            fs.Close();
        }
        public static void updateSellout(string name, string str)
        {
            FileStream fs = new FileStream(@"D:\Acer\PAP_Sellout.txt", FileMode.Append);
            StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
            //开始写入
            sw.Write("\r\n\n" + name + "---" + str + "----");
            //清空缓冲区
            sw.Flush();
            //关闭流
            sw.Close();
            fs.Close();
        }
        public static void updateaa(string name, string str)
        {
            FileStream fs = new FileStream(@"D:\Acer\sss.txt", FileMode.Append);
            StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
            //开始写入
            sw.Write("\r\n\n" + name + "---" + str + "----");
            //清空缓冲区
            sw.Flush();
            //关闭流
            sw.Close();
            fs.Close();
        }

 

简单的log

标签:

原文地址:http://www.cnblogs.com/bit-by-bit/p/4244294.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!