c# 打开文件和读取文件内容
2021-04-21 17:27
标签:def files txt gre color object led click ade c# 打开文件和读取文件内容 标签:def files txt gre color object led click ade 原文地址:https://www.cnblogs.com/cxyzhangjie/p/8266777.html private void button_Click(object sender, EventArgs e)
{
string fileName =string.Empty; //文件名
//打开文件
OpenFileDialog dlg = new OpenFileDialog();
dlg.DefaultExt = "txt";
dlg.Filter = "Txt Files|*.txt";
if (dlg.ShowDialog() == DialogResult.OK)
fileName = dlg.FileName;
if (fileName == null)
return;
//读取文件内容
StreamReader sr = new StreamReader(fileName, System.Text.Encoding.Default);
String ls_input = sr.ReadToEnd().TrimStart();
if (!string.IsNullOrEmpty(ls_input))
isopen = true;
sr.Close();
}
上一篇:企业信使短信接口API代码示例
下一篇:c# 使用正则解析html