OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = false;
dialog.Title = "请选择需要导入的Excel文件";
dialog.Filter = "文件|*.xls;*.xlsx;*.csv";
if (dialog.ShowDialog() == DialogResult.OK)
{
this.textBox1.Text = dialog.FileName;
}
if (string.IsNullOrEmpty(this.textBox1.Text))
{
MessageBox.Show("请选择一个有效文件");
return;
}
if (!File.Exists(this.textBox1.Text))
{
MessageBox.Show("您选择的文件不存在");
return;
}
var filename = this.textBox1.Text;