C# 弹窗选择配置文件
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = false;//该值确定是否可以选择多个文件
dialog.Title = "请选择文件夹";
dialog.Filter = "文本文件(*.txt*)|*.txt*";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string file = dialog.FileName;
//this.txtPath.Text = file;
Console.WriteLine(file);
}
else
{
MessageBox.Show("未选中配置文件");
}
}
浙公网安备 33010602011771号