Asp.net 写文件

    string fr = System.DateTime.Now.ToString ("yyyyMMddHHmmss");
    string fileName = "Test-"+ fr +".txt"; 
    string path = System.Configuration.ConfigurationSettings.AppSettings["Files"];  // 文件存放目录
    string pathfrom = Path.Combine(path,fileName.ToString()); //全路径名  
    System.IO.StreamWriter writer = new StreamWriter(pathfrom );

    writer.WriteLine(info);     //将字符串写到指定的文本文件
    writer.Close();

posted on 2010-06-23 10:10  AndyCai  阅读(171)  评论(0编辑  收藏  举报

导航