473,387 Members | 1,745 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,387 software developers and data experts.

Ability to select a folder path

2
Hi Everyone,

I am working in VB6 and am trying to get code that would allow a user to select a folder path. I was using the OpenFileDialog control but it doesn't work for selecting folders, only if you want to select a file.

There was someone on here before who mentioned he was able to accomplish by using an OCX called DPDLG...so I know it works somehow but I am not sure how this is done.

If anyoen could provide any help...any sample code...it would be greatly appreciated.
Nov 8 '06 #1
7 26744
albertw
267 100+
Hi Everyone,

I am working in VB6 and am trying to get code that would allow a user to select a folder path. I was using the OpenFileDialog control but it doesn't work for selecting folders, only if you want to select a file.

There was someone on here before who mentioned he was able to accomplish by using an OCX called DPDLG...so I know it works somehow but I am not sure how this is done.

If anyoen could provide any help...any sample code...it would be greatly appreciated.
hi

seems nasty, try using a dirlistbox for a change and have the clicked directory displayed in a label or textbox
Nov 8 '06 #2
tlove
2
hi

seems nasty, try using a dirlistbox for a change and have the clicked directory displayed in a label or textbox
Thank you very much for your help! Using the dirlistbox solved the problem. I appreciate it.
Nov 9 '06 #3
Killer42
8,435 Expert 8TB
Thank you very much for your help! Using the dirlistbox solved the problem. I appreciate it.
I see you have what you wanted. But for you or anyone else who is looking for alternatives, you might try the following links. I believe it is possible to use the standard Windows selection dialogue, which generally provides a nicer user experience than a dirlistbox. Hopefully, one or more of these will show how (haven't had time to check them out yet).
Nov 9 '06 #4
albertw
267 100+
hi

display a select folder dialog is actually a great solution

make a reference in your code to shell32.dll (system32)
put

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private shlShell As Shell32.Shell
  3. Private shlFolder As Shell32.Folder
  4. Private Const BIF_RETURNONLYFSDIRS = &H1
  5.  
  6.  
in your general declaration

and use

Expand|Select|Wrap|Line Numbers
  1.  
  2. Set shlShell = New Shell32.Shell
  3. Set shlFolder = shlShell.BrowseForFolder(Me.hWnd, "Select a Folder",BIF_RETURNONLYFSDIRS)
  4.  
  5.  
to call the folder dialog
simple but functional
Nov 10 '06 #5
samycbe
83
hi

how to add the dirlist component in the project?.........
Apr 9 '07 #6
Killer42
8,435 Expert 8TB
how to add the dirlist component in the project?.........
In VB6, the DirListBox control is one of the standard ones - it doesn't need to be added to the project. In the toolbox, it's a yellow folder icon.

(Possibly it's only available in the Professional and Enterprise Editions, but I don't think so.)
Apr 9 '07 #7
Hi Everyone,

I am working in VB6 and am trying to get code that would allow a user to select a folder path. I was using the OpenFileDialog control but it doesn't work for selecting folders, only if you want to select a file.

There was someone on here before who mentioned he was able to accomplish by using an OCX called DPDLG...so I know it works somehow but I am not sure how this is done.

If anyoen could provide any help...any sample code...it would be greatly appreciated.
Hello,
You can solve your Problem using your in build control.rather then using
API call.I am using Drivelist,Dirlist form control and using a label to select a folder.however in VB 2005 we can browse folder like file but in vb 6 we don't.
All though I have coded this sample in VB 2005. you can use it in vb 6 with some changes
VB 2005 CODE SAMPLE.
Expand|Select|Wrap|Line Numbers
  1. Private Sub DriveListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DriveListBox1.SelectedIndexChanged
  2.         DirListBox1.Path = DriveListBox1.Drive
  3.         Label1.Text = DirListBox1.Path
  4.     End Sub
  5.  
  6.  
  7.  
  8.     Private Sub DirListBox1_Change(ByVal sender As Object, ByVal e As System.EventArgs) Handles DirListBox1.Change
  9.         Label1.Text = DirListBox1.Path
  10.     End Sub
  11.  
Ok buddy I write the VB 6 code.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Dir1_Change()
  2.  Label1.Caption = Dir1.Path
  3. End Sub
  4.  
  5. Private Sub Drive1_Change()
  6. Dir1.Path = Drive1.Drive
  7. Label1.Caption = Dir1.Path
  8. End Sub
  9.  
I think this code fulfill your requrement .Good luck.
Apr 11 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pablo | last post by:
Friends! I need to show the dialog "select folder" and get the path selected, using vb.net. The OpenFileDialog control is useless as I want to select a folder and not a file. In vb6 I achieved...
2
by: Andrew Wiles | last post by:
Hi I have created an installation package in VS .Net. All works well if I use the default installation path. If however I change the Installation path the following message is shown. "A...
0
by: muesliflakes | last post by:
I have tried to build an Installation Project for to different applications. Both are simple. Steps Taken: * Add New Setup Project to the solution * Set the project out to the application...
0
by: Keith Smith | last post by:
When I create a setup file (MSI) for my app, I get the following error when I try to run the MSI file... The folder path '.' contains an invalid character Does anyone know a solution to this? ...
1
by: Chung | last post by:
Hi, I am developing an asp.net application. I have create some class method and I would like to get the folder path of that class method. I cannot use this.Mappath("") to get the path because...
2
by: Harshdeep Mehta | last post by:
Hi all gurus, Myself Harshdeep Mehta, you can call me Harsh. I struck up in a situation where I need to define relative path in Web.Config. I.e. suppose I have a "Export" named folder, besides...
1
by: Tempalli | last post by:
CAN DATABASE OPEND FROM THE ACTIVE FOLDER PATH WITHOUT DEFINING SUCH LONG PATH. KINDLY HELP ME. ANANTH ;------------------------------------------------------------------------------- Dim...
5
by: John A Grandy | last post by:
I don't find .net lib method to return the folder-path of a file-path. I'm probably not looking hard enough ... I've checked the System.IO.File,Path,Directory libs
5
by: remya1000 | last post by:
i'm using VB.NET 2003 application program. by using OpenFileDialog, we can select the file name or file path. OpenFileDialog1.ShowDialog() pgmPath.Text =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...

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.