选择文件夹路径的窗体

PathDlgSelect 是一个自定义的文件夹选择窗体,它允许用户在多个驱动器和子目录中选择一个文件夹。窗体包含一个树形视图组件(TreeView)展示驱动器和子目录,以及一个文本框显示所选路径。用户可以点击'选择'按钮确认选择,或点击'取消'按钮关闭窗口。窗体还处理异常,确保在枚举驱动器和目录时的稳定性。
摘要由CSDN通过智能技术生成

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;

namespace txttest2
{
 /// <summary>
 /// PathDlgSelect 的摘要说明。
 /// </summary>
 public class PathDlgSelect : System.Windows.Forms.Form
 {

  private static string driveLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  // 用于列举驱动器盘符
  private DirectoryInfo folder;
  private DevExpress.XtraEditors.SimpleButton simpleButton1;
  private DevExpress.XtraEditors.SimpleButton simpleButton2;
  private DevExpress.XtraEditors.TextEdit textEdit1;
  private System.Windows.Forms.TreeView treeView1;
  private DevExpress.XtraTreeList.TreeList treeList1;
  private System.Windows.Forms.Label label1;
  private System.Windows.Forms.Label label2;
  private System.Windows.Forms.ImageList imageList1;
  private System.Windows.Forms.TextBox textBox1;
  private System.ComponentModel.IContainer components;

  public PathDlgSelect()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //

   InitPathDlg();// 该函数调用完成目录选择对话框的初始设置
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if(components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.components = new System.ComponentModel.Container();
   System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(PathDlgSelect));
   this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton();
   this.simpleButton2 = new DevExpress.X

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值