FileStream fs = new FileStream(@"d:\service.txt", FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
using ( fs)
{
using (sw)
{
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine("WindowsService: Service Started" + DateTime.Now.ToString() + "\n");
sw.Flush();
}
}
原文:http://www.cnblogs.com/change4now/p/5665202.html