將文件寫入檔案裡,會自動產生一個檔案,把文字寫入此檔案裡
private bool CreateXml(string xml) { try { string sNow = DateTime.Today.Year.ToString() + DateTime.Now.ToString("MMddHHmmss"); string spath = @"c:\RecXml\RecsXml" + sNow + ".xml"; StreamWriter sw = File.AppendText(spath); sw.WriteLine(xml); sw.Flush(); sw.Close();
HisMessage.ShowHint("檔案寫入成功,路徑:" + spath); return true; } catch { HisMessage.ShowHint("寫入xml檔時發生錯誤"); return false; } }
沒有留言:
張貼留言