现正做一个win form小程序,需要选择一个硬盘一个目录! 
程序运行效果应该和打开文件的openFileDialog差不多,但是
打开文件对话框必须要选择一个具体文件后才能结束,我需要的是
到达我想要的目录后点击选择或确定按钮(必须要选定具体的文件),
然后把当前所在的目录提取出来,该如何实现呢?

解决方案 »

  1.   

    windows窗体-folderBrowserDialog这个是来选目录的
      

  2.   

    目录不是用openFileDialog,而是用******path的,忘记叫什么名了
      

  3.   

    你可以用System.Windows.Forms.FolderBrowserDialog,这是一个sealed class,不可继承,专门用来选择文件夹。
    你也可以不必记住所有相关的类,但是一定要记住他们的基类:System.Windows.Forms.CommonDialog。
    它有6个派生类:
    System.Windows.Forms.ColorDialog
    System.Windows.Forms.FileDialog
    System.Windows.Forms.FolderBrowserDialog
    System.Windows.Forms.FontDialog
    System.Windows.Forms.PageSetupDialog
    System.Windows.Forms.PrintDialog
    其中FileDialog包括System.Windows.Forms.OpenFileDialog和System.Windows.Forms.SaveFileDialog。你原贴里面用的就是OpenFileDialog。