473,396 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

pick up a FOLDER with a nice explorer


I want to use the ordinary OpenFileDialog to choose a folder instead
of a file. Is it possible? And how?

[I do not want to use the standard FolderBrowserDialog, because too
ugly and poor for my taste]
-P

Jul 20 '07 #1
14 2001
No, because the OpenFileDialog was not designed to "open" a folder. Now,
having said that, if the FolderBrowserDialog doesn't suit your high-fashion
couture, you are free to derive from it and "soup it up"... ;-)
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"pamela fluente" wrote:
>
I want to use the ordinary OpenFileDialog to choose a folder instead
of a file. Is it possible? And how?

[I do not want to use the standard FolderBrowserDialog, because too
ugly and poor for my taste]
-P

Jul 20 '07 #2
On Jul 20, 1:08 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yohohhoandabottleofrum.comwrote :
No, because the OpenFileDialog was not designed to "open" a folder. Now,
having said that, if the FolderBrowserDialog doesn't suit your high-fashion
couture, you are free to derive from it and "soup it up"... ;-)
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"pamela fluente" wrote:
I want to use the ordinary OpenFileDialog to choose a folder instead
of a file. Is it possible? And how?
[I do not want to use the standard FolderBrowserDialog, because too
ugly and poor for my taste]
-P

Recursion: see Recursion
That just made my day :-)

Thanks,

Seth Rowe

Jul 20 '07 #3
On Jul 20, 1:31 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
On Jul 20, 1:08 pm, Peter Bromberg [C# MVP]

<pbromb...@yahoo.yohohhoandabottleofrum.comwrote :
No, because the OpenFileDialog was not designed to "open" a folder. Now,
having said that, if the FolderBrowserDialog doesn't suit your high-fashion
couture, you are free to derive from it and "soup it up"... ;-)
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com
"pamela fluente" wrote:
I want to use the ordinary OpenFileDialog to choose a folder instead
of a file. Is it possible? And how?
[I do not want to use the standard FolderBrowserDialog, because too
ugly and poor for my taste]
-P
Recursion: see Recursion

That just made my day :-)

Thanks,

Seth Rowe
Darn google trimmed my quote again - the "Recursion: see Recursion"
quote is what I was referring to with "made my day"

Thanks,

Seth Rowe

Jul 20 '07 #4
On 20 Lug, 19:33, rowe_newsgroups <rowe_em...@yahoo.comwrote:
On Jul 20, 1:31 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
Darn google trimmed my quote again - the "Recursion: see Recursion"
quote is what I was referring to with "made my day"

That would be a nice quote, except for the fact that is an infinite
loop, not a recursion.

(That's always my "high-fashion couture")

-P


Jul 20 '07 #5
Peter Bromberg [C# MVP] wrote:
No, because the OpenFileDialog was not designed to "open" a folder.
There's something that looks suspiciously like it that *is* designed to
select a folder though. In VS2005, open the Tools/Options window, select the
root "Projects and Solutions" tree node and then click the "..." button next
to one of the location boxes at the top of the dialog. That definitely looks
like the OpenFileDialog to me, and it's selecting a folder rather than a
file.

Can the OpenFileDialog do that? I must confess I haven't tried it.

(I too find the FolderBrowserDialog quite irritating, not least of which
because you can't type in it, making all selections tedious click-fests and
also making it impossible to select folders via UNC locations).

--

(O)enone
Jul 20 '07 #6
On 20 Lug, 23:43, "\(O\)enone" <oen...@nowhere.comwrote:
Peter Bromberg [C# MVP] wrote:
No, because the OpenFileDialog was not designed to "open" a folder.

There's something that looks suspiciously like it that *is* designed to
select a folder though. In VS2005, open the Tools/Options window, select the
root "Projects and Solutions" tree node and then click the "..." button next
to one of the location boxes at the top of the dialog. That definitely looks
like the OpenFileDialog to me, and it's selecting a folder rather than a
file.

Can the OpenFileDialog do that? I must confess I haven't tried it.

(I too find the FolderBrowserDialog quite irritating, not least of which
because you can't type in it, making all selections tedious click-fests and
also making it impossible to select folders via UNC locations).

--

(O)enone
Let's discuss this idea (perhaps a stupid one).

When I explore my folders using the OpenFileDialog there must be some
place where the current folder is recorded.

Can I get that information, from environment or whatever, and return
it when the dialog is closed by the user with OK ?

If one could do that, I think we would have a nice folder browser.

(And actually I do not see why the OpenFileDialog , which is nice,
could not also serve, possibly with appropriate properties, to select
folders. It seems quite stupid to have an additional dialog, an even
an ugly one.)

-P

Jul 20 '07 #7
For instance see this:

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) _
Handles Button1.Click

Dim MyPath As String = SelectAFolder()

If MyPath IsNot Nothing Then
MsgBox("Path selected is " & MyPath)
End If

End Sub
Function SelectAFolder() As String

Dim SelectedPath As String = Nothing

Using Ofd As New OpenFileDialog
With Ofd
.RestoreDirectory = False 'crucial

If .ShowDialog() Then
SelectedPath = Environment.CurrentDirectory
End If
End With
End Using

Return SelectedPath

End Function

End Class
Now what is missing is just a slight change of behavior of the button
(ok instead of open folder). Then we would have a nice folder browser.

Can we do that ?
-P

Jul 20 '07 #8
On Fri, 20 Jul 2007 14:43:50 -0700, (O)enone <oe****@nowhere.comwrote:
Peter Bromberg [C# MVP] wrote:
>No, because the OpenFileDialog was not designed to "open" a folder.

There's something that looks suspiciously like it that *is* designed to
select a folder though. In VS2005, open the Tools/Options window, select
the
root "Projects and Solutions" tree node and then click the "..." button
next
to one of the location boxes at the top of the dialog. That definitely
looks
like the OpenFileDialog to me, and it's selecting a folder rather than a
file.

Can the OpenFileDialog do that? I must confess I haven't tried it.
It probably is based on the OpenFileDialog, though I suppose you'd have to
watch it in a debugger to be sure (or ask the guy who wrote it). You
could do something similar by creating a new dialog derived from the
OpenFileDialog and/or the native Win32 common file open dialog, and
overriding the base behavior so that the "Open" button returns with path
and no filename.

But it's a big UI mistake to do that, IMHO. I don't see what the fuss
about the folder browser dialog is. I agree it'd be nice to have better
typing control over the browser, but overloading the file browser to
return folders results in some pretty user-unfriendly behavior.

In the example you describe, contrary to what the user normally expects,
selecting a folder and clicking the "Open" button dismisses the dialog
rather than descending into the directory tree. The fact that the dialog
looks so much like the usual common dialog makes the behavior that much
worse; it should at least be visibly and significantly different from the
standard dialog, to ensure the user understands they are dealing with
something different.

The folder browser dialog makes it very clear that you're doing something
different from choosing a file. The UI is so different, there's no chance
the user will get confused about what button does what.

VS should have used the folder browser in that situation. They've
violated the basic rule of UI: the rule of least surprise.

Pete
Jul 20 '07 #9
On Fri, 20 Jul 2007 15:28:09 -0700, pamela fluente
<pa***********@libero.itwrote:
[...]
Can we do that ?
Do what? Post VB code in a C# newsgroup?

No. You're not allowed to do that.


:)
Jul 20 '07 #10
On 21 Lug, 00:40, "Peter Duniho" <NpOeStPe...@nnowslpianmk.comwrote:
On Fri, 20 Jul 2007 15:28:09 -0700, pamela fluente

<pamelaflue...@libero.itwrote:
[...]
Can we do that ?

Do what? Post VB code in a C# newsgroup?

No. You're not allowed to do that.

:)

Should we still really make a difference ?

for the C# readers only: ----------begin---------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FolderBrowserTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
string MyPath = SelectAFolder();
if (MyPath != null)
{
this.Text = "Path selected is " + MyPath;
}
}
public string SelectAFolder()
{
string SelectedPath = null;
using (OpenFileDialog Ofd = new OpenFileDialog())
{
{
Ofd.RestoreDirectory = false;
//crucial

if (Ofd.ShowDialog() == DialogResult.OK )
{
SelectedPath = Environment.CurrentDirectory;
}
}
}

return SelectedPath;
}
}
}
for the C# readers only: ----------end---------

I am still of the opinion that the 2 dialogs should be unified.

Is anybody able to simply change sligtly the behavior of the file
browser ?

-P

Jul 21 '07 #11
On 21 Lug, 00:38, "Peter Duniho" <NpOeStPe...@nnowslpianmk.comwrote:
On Fri, 20 Jul 2007 14:43:50 -0700, (O)enone <oen...@nowhere.comwrote:
Peter Bromberg [C# MVP] wrote:

In the example you describe, contrary to what the user normally expects,
selecting a folder and clicking the "Open" button dismisses the dialog
rather than descending into the directory tree.
If this were the difficulty we would be doing a different form for
anything.
Programming is about being general, unifying and reusing.

It's sufficient to have (in browse folder mode) 2 buttons: on to open
and one
to select.

Still do not see the point to create an additional dialog, especially
if it is
quite ugly and irritating to use.

-P

Jul 21 '07 #12
On Sat, 21 Jul 2007 00:59:20 -0700, pamela fluente
<pa***********@libero.itwrote:
>Do what? Post VB code in a C# newsgroup?

No. You're not allowed to do that.

:)


Should we still really make a difference ?
It was a joke. Please note the "emoticon" (aka "smiley") that I posted,
and which you quoted.
[...]
Is anybody able to simply change sligtly the behavior of the file
browser ?
You may be able to override the behavior using the standard C#
mechanisms. If not, then for sure you can override the behavior by using
the WndProc override and handling the various Windows messages. There's
all sorts of things you can do with the common dialogs via this mechanism,
if you really want to.

But read my other post. The point is that people shouldn't be going
around changing the fundamental behaviors of a shared UI element. It's
very bad for the user. If your sense of aesthetics is offended by not
having the same visual thing do different things in different contexts,
then it's your sense of aesthetics that needs fixing, not the UI element.

Pete
Jul 21 '07 #13

"pamela fluente" <pa***********@libero.itwrote in message
news:11**********************@m3g2000hsh.googlegro ups.com...
On 20 Lug, 19:33, rowe_newsgroups <rowe_em...@yahoo.comwrote:
>On Jul 20, 1:31 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
>Darn google trimmed my quote again - the "Recursion: see Recursion"
quote is what I was referring to with "made my day"


That would be a nice quote, except for the fact that is an infinite
loop, not a recursion.
It is indeed a recursive definition. And as you say, it is infinitely
recursive. But not all self-referential definitions are infinitely
recursive.
Jul 23 '07 #14
On 23 Lug, 20:16, "Ben Voigt [C++ MVP]" <r...@nospam.nospamwrote:
"pamela fluente" <pamelaflue...@libero.itwrote in message

news:11**********************@m3g2000hsh.googlegro ups.com...
On 20 Lug, 19:33, rowe_newsgroups <rowe_em...@yahoo.comwrote:
On Jul 20, 1:31 pm, rowe_newsgroups <rowe_em...@yahoo.comwrote:
Darn google trimmed my quote again - the "Recursion: see Recursion"
quote is what I was referring to with "made my day"
That would be a nice quote, except for the fact that is an infinite
loop, not a recursion.

It is indeed a recursive definition. And as you say, it is infinitely
recursive. But not all self-referential definitions are infinitely
recursive.
You may want to read some basics:

http://en.wikipedia.org/wiki/Recursion

http://en.wikipedia.org/wiki/Iteration

-P

Jul 24 '07 #15

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

Similar topics

7
by: Tom | last post by:
Can anyone give me any advice on how to secure a folder on a network server so that documents in the folder can only be opened through an Access database or by the database admin. I need to store...
3
by: Rajiv Das | last post by:
VS 2003, XP SP2 ------------------------------------------------------------ DirectoryInfo temporary = new DirectoryInfo( Environment.GetFolderPath(Environment.SpecialFolder.InternetCache));...
4
by: Santaji | last post by:
Hi, We have an ASP.NET application which needs to write some files on the disk. For these we need to give ASP.NET user the Write permission for that particular folder. This is possible from...
8
by: vinesh | last post by:
I have sample Asp.Net Web Application project. Let me know how to keep the files related to this project (like the webform.aspx, WebForm1.aspx.vb, WebForm1.aspx.resx) in a separate folder within a...
1
by: reidarT | last post by:
I have oppened a solution in Vb.net with an image folder. When I have opened vb.net and then adds an image to the image folder, it is not updated. I have to strt vb.net all over. Am I missing...
6
by: Caleb Hattingh | last post by:
Hi everyone Unless you have a nice tool handy, calculating many folder sizes for clearing disk space can be a click-fest nightmare. Looking around, I found Baobab (gui tool); the "du"...
2
by: tatemononai | last post by:
Ok, this is a very unique bug. I have only been able to find one other post related to this online, and everybody who responded misunderstood the problem. I am not trying to reference anything in...
24
by: biganthony via AccessMonster.com | last post by:
Hi, I have the following code to select a folder and then delete it. I keep getting a Path/File error on the line that deletes the actual folder. The line before that line deletes the files in...
14
by: pamela fluente | last post by:
I want to use the ordinary OpenFileDialog to choose a folder instead of a file. Is it possible? And how? -P
2
by: Kevin | last post by:
I'm trying to use a command button to open a windows folder related to the current record. The record has a Location field that contains the name of the windows folder, in the current directory...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.