using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Net.Http; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { internal class Program { static async Task Main(string[] args) { var dateName = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"); var fileName = dateName + "12345678" + ".csv"; var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName); var exsit = File.Exists(filePath); using var streamWriter = new StreamWriter(filePath, false, Encoding.UTF8); if (!exsit) { await streamWriter.WriteAsync("barcode,test_result,uut_start,uut_stop,value,shift,head_id,line_id,station_id"); await streamWriter.FlushAsync(); } } } }