zoukankan      html  css  js  c++  java
  • 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 publicpartialclass SelectFolder: Form {
     9 public SelectFolder() 
    10 {
    11 InitializeComponent();
    12 }
    13 privatevoid btnSelectPath_Click(object sender, EventArgs e) //弹出一个选择目录的对话框
    14 {
    15 FolderBrowserDialog path = new FolderBrowserDialog();
    16 path.ShowDialog();
    17 this.txtPath.Text = path.SelectedPath;
    18 }
    19 privatevoid btnSelectFile_Click(object sender, EventArgs e) //弹出一个选择文件的对话框
    20 {
    21 OpenFileDialog file = new OpenFileDialog();
    22 file.ShowDialog();
    23 this.txtFile.Text = file.SafeFileName;
    24 }
    25 }
    26 }winforms 的openFileDialog1能实现 选择文件夹里面的多个<文件名>一次导入到LISTBOX下呢 !this.openFileDialog1.Multiselect = true;this.openFileDialog1.ShowDialog();foreach(string fName in this.openFileDialog1.FileNames){ this.listBox1.Items.Add(fName);}读取选择好的,文件全地址及名称
    27 OpenFileDialog openfiledialot = new OpenFileDialog();
    28             openfiledialot.ShowDialog();
    29             this.textBox1.Text = openfiledialot.FileName.ToString();
  • 相关阅读:
    Python_反射
    Python_面向对象_类2
    Python_面向对象_类1
    Python_logging模块
    Python_子进程管理subprocess模块
    Python_python内置加密模块
    Python_configparser模块
    Python_xml
    Python_shelve模块
    Python_shutil模块
  • 原文地址:https://www.cnblogs.com/pyffcwj/p/3062604.html
Copyright © 2011-2022 走看看