jjjamie Posted November 15, 2002 Posted November 15, 2002 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? Quote
jjjamie Posted November 16, 2002 Author Posted November 16, 2002 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? Quote
*Gurus* divil Posted November 16, 2002 *Gurus* Posted November 16, 2002 http://msdn.microsoft.com/vbasic/downloads/samples/default.asp Go there. Get the sample entitled "Create an Explorer Style Application". That includes an example of showing a Directory Selection Dialog. Quote 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* Derek Stone Posted November 16, 2002 *Gurus* Posted November 16, 2002 http://www.elitevb.com/content/01,0077,01/01.aspx Quote Posting Guidelines
jjjamie Posted November 18, 2002 Author Posted November 18, 2002 (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 November 18, 2002 by divil Quote
*Gurus* divil Posted November 18, 2002 *Gurus* Posted November 18, 2002 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. Quote 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* Derek Stone Posted November 18, 2002 *Gurus* Posted November 18, 2002 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. Quote Posting Guidelines
sj1187534 Posted June 30, 2003 Posted June 30, 2003 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. Quote
Hughng Posted November 24, 2003 Posted November 24, 2003 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. Quote
Shurikn Posted July 4, 2005 Posted July 4, 2005 (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 July 4, 2005 by Shurikn Quote
FZelle Posted July 4, 2005 Posted July 4, 2005 In FW 1.0 this was the way to go. in FW 1.1 there ist the FolderBrowserDialog http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsfolderbrowserdialogclasstopic.asp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.