标签:log private mic lte lin image eve name 对话
IO流操作文件内容,using System.IO;//引入命名空间
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text==string.Empty) { MessageBox.Show("写入内容不能为空"); } else { saveFileDialog1.Filter = "文本文件(*.txt)|*.txt";//打开保存文件对话框 if (saveFileDialog1.ShowDialog()==DialogResult.OK)//单机OK按钮 { StreamWriter sw = new StreamWriter(saveFileDialog1.FileName, true);//创建写入流 sw.WriteLine(textBox1.Text);//写入 sw.Close();//关闭流 } } } private void button2_Click(object sender, EventArgs e) { openFileDialog1.Filter = "文本文件(*.txt)|*.txt"; if (openFileDialog1.ShowDialog()==DialogResult.OK) { StreamReader sr = new StreamReader(openFileDialog1.FileName);//创建读出流 textBox1.Text = sr.ReadToEnd();//读出全部内容 sr.Close();//关闭流 } }
标签:log private mic lte lin image eve name 对话
原文地址:https://www.cnblogs.com/xixixing/p/10822961.html