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

 

    1. using System.Collections.Generic;
    2.  
      using System.ComponentModel;
    3.  
      using System.Data;
    4.  
      using System.Drawing;
    5.  
      using System.Text;
    6.  
      using System.Windows.Forms;
    7.  
      namespace WindowsApplication1 {
    8.  
      public partial class SelectFolder: Form {
    9.  
      public SelectFolder()
    10.  
      {
    11.  
      InitializeComponent();
    12.  
      }
    13.  
      private void btnSelectPath_Click(object sender, EventArgs e) //弹出一个选择目录的对话框
    14.  
      {
    15.  
      FolderBrowserDialog path = new FolderBrowserDialog();
    16.  
      path.ShowDialog();
    17.  
      this.txtPath.Text = path.SelectedPath;
    18.  
      }
    19.  
      private void btnSelectFile_Click(object sender, EventArgs e) //弹出一个选择文件的对话框
    20.  
      {
    21.  
      OpenFileDialog file = new OpenFileDialog();
    22.  
      file.ShowDialog();
    23.  
      this.txtFile.Text = file.SafeFileName;
    24.  
      }
    25.  
      }
    26.  
      }
    27.  

posted on 2018-08-06 21:43  boood  阅读(79)  评论(0)    收藏  举报

导航