C# 读取txt文件

//按钮点击选择文件
private
void btnFile_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; fileDialog.Title = "请选择文件"; fileDialog.Filter = "所有文件(*.*)|*.*"; if (fileDialog.ShowDialog() == DialogResult.OK) { string file = fileDialog.FileName; //读取txt文件每行的内容以数组形式保存 string[] strs2 = File.ReadAllLines(@file, Encoding.Default); } }

 

posted @ 2020-05-20 16:31  Saunterer  阅读(1801)  评论(0编辑  收藏  举报