473,839 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12061
On 2004-02-08, MC D <no****@earthta lk.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.FolderBro wserDialog...

--
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
SHBrowseForFold er 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****@earthta lk.com> wrote in message
news:10******** *****@corp.supe rnews.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****@earthta lk.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.FolderBr owserDialog'

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.a sp>
<http://support.microso ft.com/?kbid=306285>
<http://www.gotdotnet.c om/team/vb/FolderBrowser.e xe>
<http://groups.google.c om/groups?selm=q0J KzDbmCHA.2144%4 0cpmsftngxa09>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
"MC D" <no****@earthta lk.com> wrote in message news:<10******* ******@corp.sup ernews.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
6383
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 could not be found! I checked and that file is there in the Windows\System folder. Can anyone help with this? Thanks.
2
5833
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 don't quite understand it all. I have gotten as far as getting the File Open dialog to appear and then tell me what file I chose, but if someone could help me understand how to take that file I've selected and import it using my specification,...
2
2754
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 documentation I've seen involves MFC, and I'm not using MFC. Pre-emptive thanks! Lonnie
5
3740
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 this task appriciate any help from Pro Krishna
3
2312
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 and more. I developed a windows user control in VB.NET with a button and File Open Dialog, which allows multiple file selection. I registered the assembly with regasm.exe and call the object from the html page with the object tag: <OBJECT...
0
1565
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: Assumssing that we have following HTML code <form .. > <input type="file" name="myfilebox" size=20>
5
5409
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 my colleagues that this is not "standard" but find it hard to believe. Opening a file in MS word for example, the dialog has
1
1733
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
3494
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. FileDlg.GetOFN().lpstrInitialDir = _T("<some directory>"); FileDlg.GetOFN().lpstrFile = _T("masterDefault.txt");
0
9698
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10913
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10592
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7834
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5684
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5871
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4495
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 we have to send another system

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.