472,782 Members | 1,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,782 software developers and data experts.

File open dialog... select folder only

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 altogether? I was
thinking of doing it from a treeView, but It seems like there ought to be a
control for this sort of thing!

-D
Nov 20 '05 #1
4 11997
On 2004-02-08, MC D <no****@earthtalk.com> wrote:
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 altogether? I was
thinking of doing it from a treeView, but It seems like there ought to be a
control for this sort of thing!

-D


If your using VS.NET 2003 then, you can use the
System.Windows.Forms.FolderBrowserDialog...

--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
Loose bits sink chips.
Nov 20 '05 #2
It depends on which version of VS.NET (and VB.NET) you are using. If you are
using 2003 then you are in luck. VB.NET in 2003 has a BrowseForFolder Dialog
control that you can use. Otherwise, you will have to use the
SHBrowseForFolder API.
Go to this link:
http://msdn.microsoft.com/vbasic/dow...s/default.aspx

Scroll down about half way and you will see a selection to download a code
sample for VB.NET 2002 and Framework 1.0 that will give you what you need.
james

"MC D" <no****@earthtalk.com> wrote in message
news:10*************@corp.supernews.com...
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 altogether? I was
thinking of doing it from a treeView, but It seems like there ought to be a control for this sort of thing!

-D

Nov 20 '05 #3
* "MC D" <no****@earthtalk.com> scripsit:
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 altogether? I was
thinking of doing it from a treeView, but It seems like there ought to be a
control for this sort of thing!


NET 1.1:

'System.Windows.Forms.FolderBrowserDialog'

Note that there is a bug in Fx 1.1 that causes a really bad error when using
a path which is longer than ~128 characters. This occurs on unicode systems
only. Use the PInvoke solutions mentioned below instead.

The property for hiding the button that allows the user to create a new
folder doesn't work on Windows 2000.

..NET 1.0:

<http://www.codeproject.com/cs/miscctrl/folderbrowser.asp>
<http://support.microsoft.com/?kbid=306285>
<http://www.gotdotnet.com/team/vb/FolderBrowser.exe>
<http://groups.google.com/groups?selm=q0JKzDbmCHA.2144%40cpmsftngxa09>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
"MC D" <no****@earthtalk.com> wrote in message news:<10*************@corp.supernews.com>...
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 altogether? I was
thinking of doing it from a treeView, but It seems like there ought to be a
control for this sort of thing!

-D


A twist on MC D's question.

Case one:
User is going to choose one file then OpenFileDialog works fine.

Case two:
User is going to choose more than one file, then OpenFileDialog works
fine, with a but:

I would like to save the user some clicking & scrolling, so if they
are going to choose all the files in a folder, then I would like to
give them the option of choosing the folder, but OpenFileDialog will
not work

Of course I could put 2 different buttons on my form
Button1 using FileOpen, if one file (or more than one but not all
files in folder)
Button2 using FolderBorwse in case user is going to choose all files

But the point is to simplify interface not to add more buttons...etc.

Is this possible?
Nov 20 '05 #5

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

Similar topics

2
by: Alok Joshi | last post by:
I am trying to code the functionality of a file open dialog box in Access 97 using VBA. I tried following Microsoft KB article 96114 but when I run it in Access 97 I get the message commdlg.dll...
2
by: Jim | last post by:
I am trying to import a file using a file spec from the Access File Open dialog... I have been out to http://www.mvps.org/access/api/api0001.htm to look at the code, but because I'm not a guru, I...
2
by: Lonnie | last post by:
I need to implement a simple file open dialog in my form application (C++ .NET). I know there has to be a canned version of this dialog somewhere that I can simply use, but where? How? All the...
5
by: Krishna | last post by:
Hi I want to open the file open dialog box when i click the asp.net button and when i select the particular folder, i want full path in the textbox besides it is there anyway we can accomplish...
3
by: JoNaS | last post by:
As a lot of us might now, the input file (aka browse button) in html does not allow for multiple file selection or for filtering file types. The File Open dialog used in WinForms allow these things...
0
by: John Clark | last post by:
Hi, I am using webbrowser control to automate a site. this site contains form with tage <INPUT TYPE=FILE ...> I know the control is not writeable. So, only thing that I could do was: ...
5
by: charles | last post by:
I have a question about the file Open dialog box. I would like to be able to make the dialog box bigger by selecting the bottom right-hand corner and dragging/expanding the box. I am told by...
1
by: jhaek19 | last post by:
HI, how can show the file open dialog box... i dont want to use the <input = "file"> object, i suggest a different style...
1
by: ahammad | last post by:
Hello, I need to customize a standard File Open dialog box so that when DoModal is called, the dialog box opens to a certain directory and already has preselected a file. ...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

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.