Home > Archive > Visual Basic > September 2004 > Common Dialog Directory Select
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Common Dialog Directory Select
|
|
|
| Is there any way to use the CommonDialog control to select a directory
instead of a file?
I need to import data from several files that are dropped into different
directorys depending on the content. There can be upwards of 150 files for
each dump, so selecting files individually is pretty much worthless....
Thanks,
Joe
| |
| Randy Birch 2004-09-22, 3:55 am |
| Can you do it ... yes, but I don't provide that code as it's
counter-intuitive. How about using the BrowseForFolders dialog designed for
folder-picking? ... http://vbnet.mvps.org/code/browse/browsefolders.htm
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
"Joe" <Joe@discussions.microsoft.com> wrote in message
news:F35A08F6-CCA5-41EB-9300-ED72AAB05326@microsoft.com...
: Is there any way to use the CommonDialog control to select a directory
: instead of a file?
:
: I need to import data from several files that are dropped into different
: directorys depending on the content. There can be upwards of 150 files
for
: each dump, so selecting files individually is pretty much worthless....
:
: Thanks,
: Joe
| |
|
|
"Joe" <Joe@discussions.microsoft.com> wrote in message
news:F35A08F6-CCA5-41EB-9300-ED72AAB05326@microsoft.com...
> Is there any way to use the CommonDialog control to select a directory
> instead of a file?
There is, but it's ugly as sin. It's basically a throw-back to Win3.x days
(essentially, you provide a dummy file name, specify a flag that the file
doesn't have to exist [actually do NOT include the flag that the file must
exist], and then just retrieve the path; but, if the user deletes the dummy
file name, it backfires, so it's not even a good solution).
Win95 and greater provide a Browse For Folder dialog box. Unfortunately, VB
does not include any control whatsoever to use this dialog box. So, you
have to use the API. Go to www.google.com and search on the
SHBrowseForFolder API function. You'll find TONS of example code, many
examples wrapping the code into a class module.
Mike
| |
|
| Wow, I had no idea this was such a popular question. I just assumed I had
missed a FLAG or something for the CommonDialog.
Thanks to both of you for your help!
"Joe" wrote:
> Is there any way to use the CommonDialog control to select a directory
> instead of a file?
>
> I need to import data from several files that are dropped into different
> directorys depending on the content. There can be upwards of 150 files for
> each dump, so selecting files individually is pretty much worthless....
>
> Thanks,
> Joe
|
|
|
|
|