//檔案路徑
string filePath = string.Format("{0}\\{1}.xml", Directory.GetCurrentDirectory(), DateTime.Now.ToString("HH-mm-ss"));
//判斷檔案是否存在,不存在就開一個新檔案
if (!File.Exists(filePath))
{
File.Create(filePath);
}
//開始寫檔
using (StreamWriter sw = new StreamWriter(filePath))
{
sw.WriteLine("寫檔成功");
}
//檔案路徑
string filePath = string.Format("{0}\\{1}.xml", Directory.GetCurrentDirectory(), DateTime.Now.ToString("HH-mm-ss"));
//判斷檔案是否存在,不存在就開一個新檔案
if (!File.Exists(filePath))
{
using (FileStream fs = File.Create(filePath))
{
}
}
//開始寫檔
using (StreamWriter sw = new StreamWriter(filePath))
{
sw.WriteLine("寫檔成功");
}
//檔案路徑
string filePath = string.Format("{0}\\{1}.xml", Directory.GetCurrentDirectory(), DateTime.Now.ToString("HH-mm-ss"));
//判斷檔案是否存在,不存在就開一個新檔案
if (!File.Exists(filePath))
{
using (FileStream fs = File.Create(filePath))
{
}
}
//開始寫檔
using (StreamWriter sw = new StreamWriter(filePath))
{
sw.WriteLine("寫檔成功");
}
//檔案路徑
string filePath = string.Format("{0}\\{1}.xml", Directory.GetCurrentDirectory(), DateTime.Now.ToString("HH-mm-ss"));
//開始寫檔
using (StreamWriter sw = new StreamWriter(filePath,true))
{
sw.WriteLine("寫檔成功");
}