1 回答

TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超5個(gè)贊
// 判斷文件是否存在,不存在則創(chuàng)建,否則讀取值顯示到窗體
if (!File.Exists("F:\\TestTxt.txt"))
{
FileStream fs1 = new FileStream("F:\\TestTxt.txt", FileMode.Create, FileAccess.Write);//創(chuàng)建寫入文件
StreamWriter sw = new StreamWriter(fs1);
sw.WriteLine(this.textBox3.Text.Trim() + "+" + this.textBox4.Text);//開始寫入值
sw.Close();
fs1.Close();
}
else
{
FileStream fs = new FileStream("F:\\TestTxt.txt", FileMode.Open, FileAccess.Write);
StreamWriter sr = new StreamWriter(fs);
sr.WriteLine(this.textBox3.Text.Trim() + "+" + this.textBox4.Text);//開始寫入值
sr.Close();
fs.Close();
}
- 1 回答
- 0 關(guān)注
- 1957 瀏覽
添加回答
舉報(bào)