G3012a_LPCマイコン通信テキスト出力
2025年11月11日
10:20
G3012a_pc_lpc_micon_uart_part_2
続編です
2025/11/10 月曜 goma0099
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
private void button4_Click(object sender, EventArgs e)
{
// テキスト出力
DateTime dt = DateTime.Now;
string fil_path = "UART-" + dt.ToString("yyyy-MM-dd-HHmm") + ".csv";
int lin_max,i;
string txt_buf;
Encoding enc = Encoding.GetEncoding("Shift_JIS");
using (StreamWriter wrt = new StreamWriter(fil_path, true, enc))
{
lin_max = listBox1.Items.Count;
for(i=0;i<lin_max;i++)
{
txt_buf = listBox1.Items[i].ToString();
wrt.WriteLine(txt_buf);
}
// クローズは必要ないらしい、括弧の外に出た時点でクローズされる
// 書式を統一するか、検討する事
}
}
![]()
![]()
![]()
![]()