473,498 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dialog to choose folder in vb .net 2005

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

Oct 13 '06 #1
3 6671
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
"sp********@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

Oct 13 '06 #2
<DylanCopel...@discussions.microsoft.comwrote:
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.
i want to prompt the user to name a directory. suppose i know that the
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

Oct 13 '06 #3
sp********@gmail.com wrote:
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.
The RootFolder property isn't the one you want to use. As Dylan mentioned,
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
Oct 13 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1473
by: Nicolae Fieraru | last post by:
Hi All, I just start learning Visual Studio 2002. I use C++ and I want to create a dialog application. For this I select File->New Project->Win32 Project and in the Application Settings I chose...
0
1455
by: Bryan Ax | last post by:
Every time I've worked with saving files from the web, I have always used code like the following to force a save dialog where a consumer can choose to open or save the file. string fileName =...
2
3266
by: nissiml | last post by:
hi, i'm trying to open a asp.net web page that list files from a Windows application like winword and select a file from it . what do i have to do to make it happen, is it simple ? Thanks in...
4
12038
by: MC D | last post by:
What's the best way to have a modal dialog that will only allow the selection of a FOLDER, rather than a file? Is there a property of the openFileDialog I'm missing, or is there another control...
0
1553
by: guido_brasletti | last post by:
Hi, I'm asking for help because I read dozens of threads on this subject, but I still cannot make it work. I'm developing an ASP script (running on a SBS 2k. I'm a beginner with ASP) to use on...
1
3124
by: tobesurveyor via AccessMonster.com | last post by:
Hello all, The program I am creating takes certain files found on a Pocket PC and places them on a specific directory on a network drive. It is automated in the transfering of the files, and in...
1
1878
by: Vipul Pathak | last post by:
Hi Every one, I am working on deployment of a library. When the library installs on a user's machine, I want that the installed assemblies should get listed in the "Add Reference" (AddRef)...
3
1557
by: KNC | last post by:
Hi all, I'm developing a website and deployed on webserver, it always display an authentication dialog that user must login with valid Windows user. Would anyone helps to instruct how to...
8
4663
by: Arno R | last post by:
Hi all. When I need to search for pictures, I always have too choose thumbnail-view manually. Is it possible to open the common dialog in thumbnail-view programmatically? Example ?? At the...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.