1、你可以用WinForm自己写
2、你可以调用API来实现(麻烦)
3、记得有一个SharpLib.dll你找一下吧,里面有一个这样的控件

解决方案 »

  1.   

    folderBrowseDialog ,是不是这个?
      

  2.   

    是FolderBrowseDialog,你用用,把结果告诉一下!
      

  3.   

    啊,我这里没找到FolderBrowseDialog的类??帮助里也没有!!是不是版本的原因
      

  4.   

    在帮助里到是看见了一个FolderBrowse类,但是那个类是用来支持.Net框架的,不允许在代码中使用。
      

  5.   

    TO:zoujiaming(笨笨的!) :能不能共享一下你的代码?
      

  6.   

    using VS.NET 2003,there is a FolderBrowserDialog Control in  tool box .that is what you want.
      

  7.   

    我们这里所用的版本都是VS.NET 2002 version 7.0。
    看来只能自己做了。
    在别的地方找到一段代码,希望对大家有用。
      

  8.   

    Public Class BrowseForFolder#Region " Variables "
        Dim m_Path As String
        Dim m_Description As String
        Dim m_StartPath As Locations
        Dim m_Style As Styles
    #End Region#Region " Enumerations "
        Public Enum Locations
            Desktop
            Favorites
            MyComputer
            MyDocuments
            MyPictures
            NetAndDialUpConnections
            NetworkNeighborhood
            Printers
            Recent
            SendTo
            StartMenu
            Templates
        End Enum    Public Enum Styles
            BrowseForComputer
            BrowseForEverything
            BrowseForPrinter
            RestrictToDomain
            RestrictToFilesystem
            RestrictToSubfolders
            ShowTextBox
        End Enum
    #End Region#Region " Properties "
        Public Property Path() As String
            Get
                Return m_Path
            End Get
            Set(ByVal Value As String)
                m_Path = Value
            End Set
        End Property    Public Property Description() As String
            Get
                Return m_Description
            End Get
            Set(ByVal Value As String)
                m_Description = Value
            End Set
        End Property    Public Property StartPath() As Locations
            Get
                Return m_StartPath
            End Get
            Set(ByVal Value As Locations)
                m_StartPath = Value
            End Set
        End Property    Public Property Style() As Styles
            Get
                Return m_Style
            End Get
            Set(ByVal Value As Styles)
                m_Style = Value
            End Set
        End Property
    #End Region    Public Function ShowDialog() As System.Windows.Forms.DialogResult
            Dim f As New FDialog(Me)
            Return f.ShowDialog()
        End Function    Private Class FDialog        Inherits System.Windows.Forms.Design.FolderNameEditor        Private rParentClass As BrowseForFolder        Public Sub New(ByVal r As BrowseForFolder)
                rParentClass = r
            End Sub        Public Function ShowDialog() As System.Windows.Forms.DialogResult
                Dim fBFF As New System.Windows.Forms.Design.FolderNameEditor.FolderBrowser(), r As System.Windows.Forms.DialogResult            fBFF.Description = rParentClass.Description            Select Case rParentClass.StartPath
                    Case Locations.Desktop
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.Desktop
                    Case Locations.Favorites
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.Favorites
                    Case Locations.MyComputer
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.MyComputer
                    Case Locations.MyDocuments
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.MyDocuments
                    Case Locations.MyPictures
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.MyPictures
                    Case Locations.NetAndDialUpConnections
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.NetAndDialUpConnections
                    Case Locations.NetworkNeighborhood
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.NetworkNeighborhood
                    Case Locations.Printers
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.Printers
                    Case Locations.Recent
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.Recent
                    Case Locations.SendTo
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.SendTo
                    Case Locations.StartMenu
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.StartMenu
                    Case Locations.Templates
                        fBFF.StartLocation = Windows.Forms.Design.FolderNameEditor.FolderBrowserFolder.Templates
                End Select            Select Case rParentClass.Style
                    Case Styles.BrowseForComputer
                        fBFF.Style = Windows.Forms.Design.FolderNameEditor.FolderBrowserStyles.BrowseForComputer
                    Case Styles.BrowseForEverything
                        fBFF.Style = Windows.Forms.Design.FolderNameEditor.FolderBrowserStyles.BrowseForEverything
                    Case Styles.BrowseForPrinter
                        fBFF.Style = Windows.Forms.Design.FolderNameEditor.FolderBrowserStyles.BrowseForPrinter
                    Case Styles.RestrictToDomain
                        fBFF.Style = Windows.Forms.Design.FolderNameEditor.FolderBrowserStyles.RestrictToDomain
                    Case Styles.RestrictToFilesystem
                        fBFF.Style = Windows.Forms.Design.FolderNameEditor.FolderBrowserStyles.RestrictToFilesystem
                    Case Styles.RestrictToSubfolders
                        fBFF.Style = Windows.Forms.Design.FolderNameEditor.FolderBrowserStyles.RestrictToSubfolders
                    Case Styles.ShowTextBox
                        fBFF.Style = Windows.Forms.Design.FolderNameEditor.FolderBrowserStyles.ShowTextBox
                End Select            r = fBFF.ShowDialog()            If r = Windows.Forms.DialogResult.OK Then
                    rParentClass.Path = fBFF.DirectoryPath
                End If            Return r        End Function    End ClassEnd Class
      

  9.   

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Windows.Forms.Design;namespace aaa
    {
    /// <summary>
    /// DirBrowser 的摘要说明。
    /// </summary>
    public class DirBrowser : FolderNameEditor 
     

     
    FolderBrowser fb = new FolderBrowser(); 
      
    public string Description 
     

     
    set { _description = value; } 
     
    get { return _description; } 
     

      
    public string ReturnPath 
     

     
    get { return _returnPath; } 
     

      
    public DirBrowser() { } 
      
    public DialogResult ShowDialog() 
     

     
    fb.Description = _description; 
     
    fb.StartLocation = FolderBrowserFolder.MyComputer; 
      
    DialogResult r = fb.ShowDialog(); 
     
    if (r == DialogResult.OK) 
     
    _returnPath = fb.DirectoryPath; 
     
    else 
     
    _returnPath = String.Empty; 
      
    return r; 
     

      
    private string _description = "Choose Directory"; 
     
    private string _returnPath = String.Empty; 
     
    }
     }
      

  10.   

    用TreeView
    返回当前选择的目录
      

  11.   

    调用方法:
    private void button3_Click(object sender, System.EventArgs e)
    {
    DirBrowser dlg = new DirBrowser();
    dlg.Description = "目录选择";
    if (dlg.ShowDialog() == DialogResult.OK )
    MessageBox.Show(dlg.ReturnPath);

    }
      

  12.   

    谢谢谢谢~!已经解决了,呵呵
    suosuoyyy(羊羊) 兄弟的代码很管用!!
    不过有点不明白,在我的环境中都看不到FolderBrowser类,但是竟然能用?这是为什么?