Winform选择目录路径与选择文件路径

    1. private void btnSelectPath_Click(object sender, EventArgs e) //弹出一个选择目录的对话框
    2.  
      {
    3.  
      FolderBrowserDialog path = new FolderBrowserDialog();
    4.  
      path.ShowDialog();
    5.  
      this.txtPath.Text = path.SelectedPath;
    6.  
      }
    7.  
      private void btnSelectFile_Click(object sender, EventArgs e) //弹出一个选择文件的对话框
    8.  
      {
    9.  
      OpenFileDialog file = new OpenFileDialog();
    10.  
      file.ShowDialog();
    11.  
      this.txtFile.Text = file.SafeFileName;
    12.  
原文地址:https://www.cnblogs.com/ljsjxr/p/11851215.html