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); } }