By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,599 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Get Folder

P: n/a
Hi,
Is there a way to use the OpenFileDialog to retrieve a directory?

I need to allow the user to set a directory and it may not have any files in
it.

Doug
Nov 21 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
doug there is another object for this.

FolderBrowserDialog

HTH,

shane
"Doug Bell" <dug@bigpond> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi,
Is there a way to use the OpenFileDialog to retrieve a directory?

I need to allow the user to set a directory and it may not have any files in it.

Doug

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.745 / Virus Database: 497 - Release Date: 8/27/2004
Nov 21 '05 #2

P: n/a
"Doug Bell" <dug@bigpond> schrieb
Is there a way to use the OpenFileDialog to retrieve a directory?
Hi Doug,

if the directory is empty, no.
I need to allow the user to set a directory and it may not have any files
in
it.


Another possibility is to use the FolderBrowserDialog and to check whether
the selected directory contains files or not:

If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
Dim di As DirectoryInfo = New DirectoryInfo( _
FolderBrowserDialog1.SelectedPath)
If di.GetFiles.Length > 0 Then
MessageBox.Show("...")
End If
End If

Cheers

Arne Janning
Nov 21 '05 #3

P: n/a
* "Doug Bell" <dug@bigpond> scripsit:
Is there a way to use the OpenFileDialog to retrieve a directory?


..NET 1.1:

'FolderBrowserDialog' Class ('System.Windows.Forms.FolderBrowserDialog')
<URL:http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWindowsFormsFolderBrowserDialogClassTop ic.asp>

Note that there is a bug in the .NET Framework 1.1 that causes a really bad
error when using a path longer than about 128 characters. This occurs on
Unicode systems only. Use the p/invoke solutions listed below instead.

..NET 1.0:

Folder Browser component for .NET
<URL:http://www.codeproject.com/cs/miscctrl/folderbrowser.asp>

HOW TO: Implement a Managed Component that Wraps the Browse For Folder
Common Dialog Box by Using Microsoft Visual Basic .NET
<URL:http://support.microsoft.com/?kbid=811004>

FolderBrowser.msi
<URL:http://www.gotdotnet.com/team/vb/FolderBrowser.exe>

How to pick a directory
<URL:http://groups.google.com/groups?selm=q0JKzDbmCHA.2144%40cpmsftngxa09>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4

P: n/a
I was writing this already that this message would come, however to be sure
I waited (The word terrrible is disapeared, some reason)

:-)

Cor
Nov 21 '05 #5

P: n/a
The bug you mention, is that this one?
http://support.microsoft.com/?kbid=830920

If so, looks like it will get fixed in .NET 1.1 SP 1 (due in Sep)
http://msdn.microsoft.com/netframewo...tent11sp1.aspx

Greg

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2p************@uni-berlin.de...
Note that there is a bug in the .NET Framework 1.1 that causes a really bad error when using a path longer than about 128 characters. This occurs on
Unicode systems only.

Nov 21 '05 #6

P: n/a
Greg,

Great post.

I see Herfrieds next post already

Note that there is a bug in the .NET Framework 1.1 without SP1 that causes a
really bad error when using a path longer than about 128 characters.

Description of the bug
http://support.microsoft.com/?kbid=830920

Fixes in.NET 1.1 SP 1
http://msdn.microsoft.com/netframewo...tent11sp1.aspx

:-)

Herfried feel free to copy this

:-)

Cor
Nov 21 '05 #7

P: n/a
* "Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> scripsit:
The bug you mention, is that this one?
http://support.microsoft.com/?kbid=830920

If so, looks like it will get fixed in .NET 1.1 SP 1 (due in Sep)
http://msdn.microsoft.com/netframewo...tent11sp1.aspx


Yes, that's the bug I was talking about. I'll update my FAQ. Thanks
for making me aware of that.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #8

P: n/a
Thanks,
The Class Module FolderBrowserDialog works fine.

"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:OV*************@TK2MSFTNGP12.phx.gbl...
doug there is another object for this.

FolderBrowserDialog

HTH,

shane
"Doug Bell" <dug@bigpond> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
Hi,
Is there a way to use the OpenFileDialog to retrieve a directory?

I need to allow the user to set a directory and it may not have any
files in
it.

Doug

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.745 / Virus Database: 497 - Release Date: 8/27/2004

Nov 21 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.