Jump to content
Xtreme .Net Talk

Recommended Posts

Guest Morgon
Posted

I've spent a number of hours trying to research any controls, built-in, or custom, to allow for just Directory/Folder/Drive accesses, so that I may create and/or set a directory.. much like Winzip's "Move Archive" function, or any other program out there that lists the computer's directories (with things like "My Documents" and "My Network Places" special folders, as well)

 

I find it hard to believe something so used would have to be custom, with a bunch of lines of code... so I am almost convinced that I've overlooked something.

 

Heellllppp!! :-)

-Morgon

Guest Morgon
Posted

Apparently, the functionality for this was removed in post-Beta builds of VB.NET .. are you sure you got it to work (with a release version of VB.NET?)

All of the examples I've found by searching Google come up with the same error: FolderNameEditor is not defined.

 

Have you, or anyone else reading this, found a way to get any sort of directory browser working? :-|

 

--Morgon

  • *Gurus*
Posted

re: Thinker

 

A lot of the parent classes use various "supporting classes" that Microsoft didn't feel like testing or documenting thoroughly, so they chuck this message in there to warn us. Based on my experience you can simply ignore the message and use the class anyway.

 

-CL

Guest Morgon
Posted

'Namespace or type 'DLL' for the Imports 'System.Design.DLL' cannot be found.' :-| .. I'm not sure what else to do here.. this is completely ridiculous for MS to not provide some functionality for this upfront. Its in just about every program I use, in some form ..

 

Do you have your sample code handy anywhere, divil? I'd love to see.. lol..

 

--Morgon

 

 

It's definitely there in the final, I've had it working. You must not have referenced the correct assembly (System.Design.DLL I think).
  • *Gurus*
Posted
No I don't, sorry. That error would indicate what I said before, that you haven't referenced the correct DLL. That doesn't just mean with an imports statement, you have to add the DLL to your project referenced too.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Guest Morgon
Posted

Thanks divil!!

 

Okay, for anyone who's been waiting for the final solution, I will be the nice one and put it all here :D

 

First, the class:

 Public Class clsFolderBrowser
       Inherits FolderNameEditor
       Dim mo_FB As New FolderBrowser()

       Public Sub New()
           MyBase.new()
           mo_FB.Style = FolderNameEditor.FolderBrowserStyles.RestrictToFilesystem
           mo_FB.StartLocation = FolderBrowserFolder.Desktop ' Seems to be limited to this enumeration
       End Sub

       Public Sub ShowDialog()
           mo_FB.ShowDialog()
       End Sub

       Public ReadOnly Property DirectoryPath() As String
           Get
               Return mo_FB.DirectoryPath
           End Get
       End Property

       Public WriteOnly Property Description() As String
           Set(ByVal Value As String)
               mo_FB.Description = Value
           End Set
       End Property

   End Class

 

Then, you would normally call this from a button event to fill a textbox , so the code can be:

Dim fBrowser As New clsFolderBrowser()
fBrowser.Description = "Select a Folder"
fBrowser.ShowDialog()
If FB.DirectoryPath <> "" Then
     txtbox1.Text = FB.DirectoryPath
End IF

 

I hope this helps someone besides myself! Thanks to divil and everyone else who contributed :)

 

--Morgon

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...