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("未选中配置文件");
            }
        }

  

posted @ 2022-02-05 22:01  sethnie  阅读(207)  评论(0编辑  收藏  举报