|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
dialog to choose folder in vb .net 2005how do i create a dialog to allow the user to choose a folder? i tried FolderBrowserDialog but encountered a couple of problems: - when you specify the starting location (property RootFolder) you have to supply a constant such as MyComputer, you're not allowed to supply a literal value such as "C:\path\to\whatever". - once you specify the RootFolder, the user isn't allowed to navigate any higher than that in the directory tree. class OpenFileDialog behaves as i need, except that it forces the user to specify a file, and i want to prompt the user for a directory. excel VBA supports Application.FileDialog(MsoFileDialogFolderPicker) which is exactly what i need except that i can't find an equivalent in VB .NET 2005. any ideas? many thanks eric The best way to do that would be to use the Folder Browser Dialog. In your
post you say "once the user selects the root folder they can't navigate any higher" or something of that sort. The root folder is the highest folder. --------------- -Dylan Copeland http://www.dc-studios.net http://www.vbdotnetforum.com Show quoteHide quote "spamsink42@gmail.com" wrote: > hello > > how do i create a dialog to allow the user to choose a folder? > > i tried FolderBrowserDialog but encountered a couple of problems: > - when you specify the starting location (property RootFolder) you have > to supply a constant such as MyComputer, you're not allowed to supply a > literal value such as "C:\path\to\whatever". > - once you specify the RootFolder, the user isn't allowed to navigate > any higher than that in the directory tree. > > class OpenFileDialog behaves as i need, except that it forces the user > to specify a file, and i want to prompt the user for a directory. > excel VBA supports Application.FileDialog(MsoFileDialogFolderPicker) > which is exactly what i need except that i can't find an equivalent in > VB .NET 2005. > > any ideas? > > many thanks > eric > > <DylanCopel***@discussions.microsoft.com> wrote:
> The best way to do that would be to use the Folder Browser Dialog. In your i want to prompt the user to name a directory. suppose i know that the> post you say "once the user selects the root folder they can't navigate any > higher" or something of that sort. The root folder is the highest folder. user will usually choose "c:\foo", but that she will occasionally choose "c:\bar". i want to launch the dialog with it already pointing to "c:\foo" and usually the user will click OK. but in those exceptional cases where the the user wants c:\bar, she would navigate up to c: then down to c:\foo. this is a simplified example. in reality my default location would be something like "c:\path\to\whatever" but the user must have the possibility to select any folder anywhere. so there are two problems with FolderBrowserDialog: 1) whatever I specify for RootFolder, the user can go no higher, so i have to specify the highest possible location, i.e. MyComputer, even though the user usally wants "c:\path\to\whatever". 2) RootFolder only accepts predefined constants like MyComputer so in fact i can't set it to an arbitrary location like "c:\path\to\whatever". i want a dialog which will allow me to specify any location as the default startup value, and will allow the user to navigate upward from that location. regards eric spamsink42@gmail.com wrote:
> i want to launch the dialog with it already pointing to "c:\foo" and The RootFolder property isn't the one you want to use. As Dylan mentioned, > usually the user will click OK. but in those exceptional cases where > the the user wants c:\bar, she would navigate up to c: then down to > c:\foo. the root folder is the highest folder you allow the user to browse to, so for example you might set this to "C:\Program Files" if you wanted to force the user to select a folder below that. Instead, you want to use the SelectedPath property. Don't set RootFolder at all, but set SelectedPath to "C:\Foo" or wherever you want. The dialog will initially open to that location, but will let the user navigate anywhere they want to go. When they click OK, you can read the folder they selected back from the same property. HTH, -- (O)enone
Threading a ShowDialog? - progress form.
is there any way to find the position of mouse click on a form SQL datasources Help with Merge and INSERT/UPDATE commands Why return false? Command Prompt or Windows OPEN A FILE FOR READ ONLY SQL datasources How to programatically check if an application has hang ? Setup problem VB.net 2005 |
|||||||||||||||||||||||