public string Report() { { SerialPortTran spt = this.ITAG.spt; var dinfo = new DeviceInfo(spt.SendGetInfo()); string filename = dinfo.sn + ".txt"; if (File.Exists(filename)) { File.Delete(filename); } StreamWriter sw = new StreamWriter(filename); Console.WriteLine("===============" + DateTime.Now.ToString() + "==========================================================================="); sw.WriteLine("===============" + DateTime.Now.ToString() + "==========================================================================="); string deviceinfo = dinfo.ToString(); Console.WriteLine(deviceinfo); sw.WriteLine(deviceinfo); var dsetting = new DeviceSetting(spt.SentGetSetting()); string devicesetting = dsetting.ToString(); Console.WriteLine(devicesetting); sw.WriteLine(devicesetting); string temps = spt.SentGetRecords(); //Console.WriteLine(temps); string s = TempSenHelper.GetTempListCString(temps, spt.ItemCount, dinfo.RecordDateTime, dsetting.recordIntervalInSecond); sw.WriteLine(s); //Console.WriteLine(s); Console.WriteLine("===============end" + DateTime.Now.ToString() + "==========================================================================="); sw.WriteLine("===============end" + DateTime.Now.ToString() + "==========================================================================="); sw.Close(); this.textBox1.Text = File.ReadAllText(filename, Encoding.UTF8); Process vProcess = Process.Start(Directory.GetCurrentDirectory() + "\\" + filename); return(""); } }