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();
  • 相关阅读:
    23.2 编写笨的程序
    python面向对象
    面向对象封装
    python新式类删改查
    os模块sys模块 进度条实例
    选课系统练习程序
    python类相关
    xml模块
    json&pickle模块shelve模块
    Python写的ATM程序
  • 原文地址:https://www.cnblogs.com/pyffcwj/p/3062604.html
Copyright © 2011-2022 走看看