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();
  • 相关阅读:
    stark
    MySQL与JDBC
    存储过程/视图/触发器
    MyCat部署运行(Windows环境)与使用步骤详解
    常用单词总结
    表单校验---validation检验
    jQuery简介
    javascript简单介绍
    HTML&&CSS
    消息队列Java的简单实现
  • 原文地址:https://www.cnblogs.com/pyffcwj/p/3062604.html
Copyright © 2011-2022 走看看