string strPath = 获取文件所在路径
if (!File.Exists(strPath + "\\log.txt"))
{
FileStream fs = File.Create(strPath + "\\log.txt");
fs.Close();
}
try
{
StreamWriter sw = File.AppendText(strPath + "\\log.txt");
sw.WriteLine("写入文件的内容");
sw.Close();
}
catch(Exception e)
{
}
希望有所帮助