473,569 Members | 2,844 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FolderBrowserDi alog doesn't initialize

I'm trying to have the user browse to a folder, once they click a
button, using the standard FolderBrowserDi alog tool,
System.Windows. Forms.FolderBro wserDialog. I'm using VB.Net 2005.
There is a property, SelectedPath, that you're supposed to be able to
set that will initialize the folder browser window so that the tree
structure is already opened at that folder. The problem is that it
doesn't seem to work. No matter what I put, it has all the folders
and drives collapsed. It doesn't start off with the one I want open.
Anyone else experience this?

The help says:
"If the SelectedPath property is set before showing the dialog box,
the folder with this path will be the selected folder, as long as
SelectedPath is set to an absolute path that is a subfolder of
RootFolder (or more accurately, points to a subfolder of the shell
namespace represented by RootFolder)."

I want them to be able to pick any folder on their computer, and not
be limited to just those folders in a certain folder, like My
Documents, so I set RootFolder = Environment.Spe cialFolder.MyCo mputer.
Regards,
ImageAnalyst
' Root folder has to be one of the special folders.
Me.FolderBrowse rDialog1.RootFo lder =
Environment.Spe cialFolder.MyCo mputer

' Determine which folder they're about to start browsing
from.
' Doesn't work!
FolderBrowserDi alog1.SelectedP ath = "C:\Program Files"
' Show the FolderBrowserDi alog opened at above folder
(doesn't work).
Dim result As DialogResult =
FolderBrowserDi alog1.ShowDialo g()

Mar 11 '07 #1
3 6713
Well maybe it is sort of picking it - I just couldn't see it because
of the low contrast on my notebook computer. But it only highlights
the folder and doesn't have it expanded to show all the subfolders.
Anyone know how to get it to expand the selected path? Like in my
example below, have Program Files folder be selected and expanded so
that all the subfolders of Program Files are shown and the user
doesn't have to double click to get it to expand. (I'd just like to
save them a step if possible).
Regards,
ImageAnalyst

On Mar 11, 3:09 pm, "ImageAnaly st" <imageanal...@m ailinator.com>
wrote:
I'm trying to have the user browse to a folder, once they click a
button, using the standard FolderBrowserDi alog tool,
System.Windows. Forms.FolderBro wserDialog. I'm using VB.Net 2005.
There is a property, SelectedPath, that you're supposed to be able to
set that will initialize the folder browser window so that the tree
structure is already opened at that folder. The problem is that it
doesn't seem to work. No matter what I put, it has all the folders
and drives collapsed. It doesn't start off with the one I want open.
Anyone else experience this?

The help says:
"If the SelectedPath property is set before showing the dialog box,
the folder with this path will be the selected folder, as long as
SelectedPath is set to an absolute path that is a subfolder of
RootFolder (or more accurately, points to a subfolder of the shell
namespace represented by RootFolder)."

I want them to be able to pick any folder on their computer, and not
be limited to just those folders in a certain folder, like My
Documents, so I set RootFolder = Environment.Spe cialFolder.MyCo mputer.
Regards,
ImageAnalyst

' Root folder has to be one of the special folders.
Me.FolderBrowse rDialog1.RootFo lder =
Environment.Spe cialFolder.MyCo mputer

' Determine which folder they're about to start browsing
from.
' Doesn't work!
FolderBrowserDi alog1.SelectedP ath = "C:\Program Files"
' Show the FolderBrowserDi alog opened at above folder
(doesn't work).
Dim result As DialogResult =
FolderBrowserDi alog1.ShowDialo g()

Mar 11 '07 #2
ImageAnalyst wrote:
I'm trying to have the user browse to a folder, once they click a
button, using the standard FolderBrowserDi alog tool,
You must understand that "SelectedPa th" means just that - Selected. It
doesn't mean - OpenThePath or ExpandThePath.

The quickest way I could think of to achieve your required result is as
follows (watch for wrapping) -

With FolderBrowserDi alog1
Dim sString() As String =
System.IO.Direc tory.GetDirecto ries("C:\Progra m Files", "*.",
SearchOption.To pDirectoryOnly)
.SelectedPath = sString(0)
Dim result As DialogResult = .ShowDialog
End With

Obviously you'd need to add Error Handling etc., but this should get you
started. Hopefully someone else will know of a better way.
ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Mar 11 '07 #3
ShaneO:
Sorry for the late thanks. I did use your workaround (regarding
opening a subfolder) and it works fine.
Thanks,
ImageAnalyst

On Mar 11, 7:07 pm, ShaneO <spc...@optusne t.com.auwrote:
ImageAnalystwro te:
I'm trying to have the user browse to a folder, once they click a
button, using the standard FolderBrowserDi alog tool,

You must understand that "SelectedPa th" means just that - Selected. It
doesn't mean - OpenThePath or ExpandThePath.

The quickest way I could think of to achieve your required result is as
follows (watch for wrapping) -

With FolderBrowserDi alog1
Dim sString() As String =
System.IO.Direc tory.GetDirecto ries("C:\Progra m Files", "*.",
SearchOption.To pDirectoryOnly)
.SelectedPath = sString(0)
Dim result As DialogResult = .ShowDialog
End With

Obviously you'd need to add Error Handling etc., but this should get you
started. Hopefully someone else will know of a better way.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.

Apr 1 '07 #4

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

Similar topics

0
1853
by: Anja | last post by:
I have installed the new Visual Studio 2003 and implemented the FolderBrowserDialog. Everything works fine, if I open the FolderBrowserDialog before opening a Database Connection. If I open the FolderBrowserDialog after I opened the database connection no folders will be displayed in the FolderBrowserDialog. It's empty.
1
14482
by: alf | last post by:
Hi, I am using a FolderBrowserDialog to allow the user to select a folder as follows: FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog(); folderBrowserDialog1.RootFolder = System.Environment.SpecialFolder.MyComputer; folderBrowserDialog1.SelectedPath = "D:\\"; folderBrowserDialog1.ShowDialog();
9
2418
by: hhh12347 | last post by:
FolderBrowserDialog crashes on my Windows 2000 computer. Here is a C# test program: using System; using System.Windows.Forms; public class TestForm : Form { FolderBrowserDialog folderBrowserDlg; OpenFileDialog openFileDlg;
0
1048
by: Alpha | last post by:
My FolderBrowserDialog shows just the description on the top then 3 buttons (OK, Cancel, NewFolder) at the buttom of the dialog. It doesn't desplay the directory tree. I even specified not to show the NewFolder button and it still has it there. How can I fix this problem? Thanks, Alpha private void btnDirBrowser_Click(object sender,...
6
1780
by: John Krueger | last post by:
The FolderBrowserDialog control in my toolbox has vanished! I did not delibratly remove it and it is just not there anymore. I tried to add it back to the toolbox but there isn't even a .NET component (or even a COM) available to select from in the "Customize Toolbox" window! I noticed there is a RESET button on the "Customize Toolbox"...
5
7333
by: Scott M. Lyon | last post by:
My application (a VB.NET 2003 WinApp) currently has first an OpenFileDialog (asking for an input file to the process I'm working on), and then once the user selects that, it brings up a FolderBrowserDialog box (asking for a destination for the output files from the process to be saved). The OpenFileDialog works beautifully. The...
4
1871
by: hotmit | last post by:
I'm trying to create a program that dynamicly saves and loads path of a FolderBrowserDialog , but I ran into a problem. Since FolderBrowserDialog is not a Control, therefore it doesn't have attribute such as Name. How do I get the name of a Component or unique string to identify each FolderBrowserDialog instances in the my form. I tried...
3
22304
by: antuantuan | last post by:
Hi. How can I initialize a FolderBrowserDialog choosing a particular RootFolder? I saw that FolderBrowserDialog has a RootFolder member, but it accepts only an Environment.SpecialFolder (but I don't want to choose a SpecialFolder for my FolderBrowserDialog). I hope I've been clear. Thanks in advance
2
3147
by: Marcel Brekelmans | last post by:
Hi, I'm trying to display a MessageBox after a FolderBrowserDialog. I see that it gets displayed, but not activated. The form is not in front and when I have some other forms open the MessageBox is hidden behind them. The problem seems to occur only after using the FolderBrowserDialog. Has anyone seen this before? Thanks
0
7922
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. ...
0
8119
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...
1
7668
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6281
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...
1
5509
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...
0
5218
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2111
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
0
936
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.