//檔案路徑
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("寫檔成功");
}
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.
評論 1
應改用以下寫法:
XXXXXX
或是:
YYYYYY
不過文章裡XXXXXX與YYYYYY兩段程式碼好像一膜一樣?