public void Write(string words)
{
var pathUrl = Server.MapPath("/UpFile/CamInfo");
if (!Directory.Exists(pathUrl))
{
Directory.CreateDirectory(pathUrl);
}
var path = pathUrl + "/" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
FileStream fs = new FileStream(path, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
//开始写入
sw.Write(words);
//清空缓冲区
sw.Flush();
//关闭流
sw.Close();
fs.Close();
}
时间: 2024-10-24 19:40:47