Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
Does anyone know where the directory browser control is in .NET? I can see the one that's there for compatability (DirListBox control) but it looks old. I need the one that looks like the FileSave dialog. Any ideas?
Posted
I have been searching the net high and low but I can only find examples for C#. Does anyone know of a way I can display a select folder dialog without having to make my own?
Posted (edited)

I posted a lengthy reply to this but it hasn't been copied across from the old forum (http://www.visualbasicforum.com). Thanks for your help guys.

 

[edit]Here you go - divil[/edit]

 

Thanks guys :)

 

I was looking at the source code and this is what I found:

 

Imports System.Windows.Forms

' This class is needed because the 
' System.Windows.Forms.Design.FolderNameEditor.FolderBrowser is Protected and thus 
' is not accessible in this context. Deriving a Public class from it enables you to
' use the dialog in your code.
Public Class FolderBrowser
Inherits System.Windows.Forms.Design.FolderNameEditor

   Public Shared Function ShowDialog() As String
	Dim fb As New FolderBrowser()
       fb.Description = "Select a Directory to Scan"
       fb.Style = Design.FolderNameEditor.FolderBrowserStyles.RestrictToFilesystem
       fb.ShowDialog()

       Return fb.DirectoryPath
   End Function
End Class

 

Why have Microsoft made the class protected? They have given no documentation on the FolderBrowser class. In the help files it says 'The FolderNameEditor.FolderBrowser type supports the .NET Framework infrastructure and is not intended to be used directly from your code.'.

 

I find this strange us I have seen a lot of people on forums asking how to create one. (Now I know the answer!)

 

Cheers.

Edited by divil
  • *Gurus*
Posted
They want to discourage it as a user interface element I guess. The Visual Studio IDE uses an OpenFileDialog to select folders, I've noticed. It can actually make quite a good folder selection dialog, because when you turn off the display of files it becomes clear that folders are what you're selecting.

MVP, Visual Developer - .NET

 

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

 

My free .NET Windows Forms Controls and Articles

  • *Gurus*
Posted
While I partially agree with what divil offered, I have to think that it's more of a tactic by Microsoft to leave functions that haven't been thoroughly tested undocumented. I don't blame them for doing so, as the framework is rather "young". I doubt divil or I can really back up either of our theories on the matter, but they certainly do make us wonder.
  • 7 months later...
Posted

Hi...I am trying to sue this class in my application. But I cant find the FolderNameEditor in the Syste.Web.Forms.Design namespace. You were saying that we can write a public class if we want to use the Protected FolderNameEditor.FolderBrowser class. How can we do that?

 

Thanks,

SJ

 

I posted a lengthy reply to this but it hasn't been copied across from the old forum (http://www.visualbasicforum.com). Thanks for your help guys.

 

[edit]Here you go - divil[/edit]

 

Thanks guys :)

 

I was looking at the source code and this is what I found:

 

Imports System.Windows.Forms

' This class is needed because the 
' System.Windows.Forms.Design.FolderNameEditor.FolderBrowser is Protected and thus 
' is not accessible in this context. Deriving a Public class from it enables you to
' use the dialog in your code.
Public Class FolderBrowser
Inherits System.Windows.Forms.Design.FolderNameEditor

   Public Shared Function ShowDialog() As String
	Dim fb As New FolderBrowser()
       fb.Description = "Select a Directory to Scan"
       fb.Style = Design.FolderNameEditor.FolderBrowserStyles.RestrictToFilesystem
       fb.ShowDialog()

       Return fb.DirectoryPath
   End Function
End Class

 

Why have Microsoft made the class protected? They have given no documentation on the FolderBrowser class. In the help files it says 'The FolderNameEditor.FolderBrowser type supports the .NET Framework infrastructure and is not intended to be used directly from your code.'.

 

I find this strange us I have seen a lot of people on forums asking how to create one. (Now I know the answer!)

 

Cheers.

  • 4 months later...
Posted
Yes, it is not fully tested in .NET 2003 version. It also contains some bugs. One of the bug I found is that if you path length really long then you get exception raise when getting the path length. It is unpredictable when it happened. Basically, I start getting error around 155 characters or above.
  • 1 year later...
Posted (edited)

sorry to bring back an old topic like that but....

 

C:\Documents and Settings\Nicolas Dufour\Mes documents\Visual Studio Projects\HoraireInstaller\Form1.cs(589): The type or namespace name 'FolderNameEditor' does not exist in the class or namespace 'System.Windows.Forms.Design' (are you missing an assembly reference?)

 

I cant use the class... but i can run his exemple just fine, anyone can tell me what's wrong? maybe a part I didnt see?

i re-wrote the code in c# by the way so I might have missed something...

I included my code below so anyone chan chec what I did wrong...

 

Edit: Ok I just fond out... and I feel dumb... System.Windows.Forms.FolderBrowserDialog

so nevermind this

Edited by Shurikn

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...