码迷,mamicode.com
首页 > Windows程序 > 详细

C# 文件操作(一)

时间:2015-08-11 15:27:20      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

1、说明:

写入文件内容,如果文件中有内容,则进行追加,目录是程序集下的目录

public static void WriteLog(string value)
{

  try
  {

    //目录是程序集下的Debug目录
    string strPath = AppDomain.CurrentDomain.BaseDirectory + "\\Error.txt";
    StreamWriter sw = new StreamWriter(strPath, true);
    sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + " : " );
    sw.Close();
    sw.Dispose();
  }
  catch (Exception ex)
  {
    throw new Exception(ex.Message);
  }

 

C# 文件操作(一)

标签:

原文地址:http://www.cnblogs.com/longhao510/p/File.html

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