コード例 #1
0
 /// <summary>
 /// CSVファイルを出力
 /// </summary>
 /// <param name="type"></param>
 /// <param name="sdate"></param>
 /// <param name="edate"></param>
 private void SaveCsvFile(LogType type, DateTime?sdate, DateTime?edate)
 {
     this.saveFileDialog.FileName = DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".csv";
     if (this.saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         DataTable logData = null;
         using (SqlAccessor accessor = Accessor.AccessorFactory.GetSqlAccessor())
         {
             logData = accessor.GetLogCsv(type, sdate, edate);
         }
         string filePath = this.saveFileDialog.FileName;
         string csvData  = GetCsvFile(logData);
         System.Text.Encoding Encoder = System.Text.Encoding.Default;
         System.IO.File.WriteAllText(filePath, csvData, Encoder);
     }
 }