Link to home
Start Free TrialLog in
Avatar of ckchew666

asked on

How to open a folder in VB6?


Does anyone here know how to open a folder lets' say xyz located in C Drive using VB6? Basically I need the short codes. Thx.
Avatar of mugman21

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of awabid

what do u mean by OPEN THE FOLDER??? do u want a window to be opened... (shell execute the command "explorer [Folder Full Path]"... or u want to get the contents... i mean files from that???? well in that case the code will be different.... please explain the question in layman terms... coz i could not get u.... i m sorry

A W Abid
There are 2 ways I can think of to do this you can either broswe to the folder you want to use using drive, directory boxs etc or you can specify which folder you want to open in the code for example do you want to open C:\Program Files\ in the code or do you want to browse to it first?
'Use could use this code:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal _
lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Private Const SW_SHOWNORMAL = 1

'when clicking on button Command1 explorer will open folder C:\xyz if it exists.
Private Sub Command1_Click()
  ShellExecute 0, "Open", "C:\xyz", vbNullString, vbNullString, SW_SHOWNORMAL
End Sub

that's basically the exact same thing in the link I posted above, you only changed the path...... Woo Hoo

Im sorry, I just thought ckchew666 might have been too lazy to read the answer in your link.
If he/she is so lazy they can't click on a single link, then they must not want an answer that bad.