We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


VB6 Directory Path

Gary2397 asked
Medium Priority
Last Modified: 2011-10-03
I have a VB6 application that has a DriveListBox, DirListBox, and FileListBox. Currently in the application I have hard coded the directory path for the DriveListBox and the DirListBox for the directory I have mapped on my machine. The DriveListBox and DirListBox point to files in an application folder on the mapped directory. Now, this application will be distributed to other users. Not every user will have the same drive letter as my mapped directory. Is there a way to program to where the directory can be located and not dependant upon the drive letter.

The current code is:

Private Sub Form_Load()
Dir1.Path = "G:\data\reports"
Drive1.Drive = "G"
End Sub
Watch Question

SQL Server Data Dude
Most Valuable Expert 2013
Author of the Year 2015
(Wild guess)  You could try feeding it the UNC path, as in Dir1.Path = "\\Server\data\reports", and let the user's pc figure out which drive letter it is.

Also, it wouldn't be a bad idea to validate if that share exists on the target pc first.  Something like using fso.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
leclairm.Net Developer  ERP integration

Also, you should store the path the user selects in an ini file.

You use the WritePrivateProfileString and GetPrivateProfileString api's to write/read values with ini files.
i think "App.Path" returns the path you are looking for
but Attention: This is the path of the "EXE" file. So in IDE (during debugging) this points to the VB installaion path, but compiled it works like expected
leclairm.Net Developer  ERP integration

I think he wants to point to a server path that the application references.  Although I could be mistaken...


Yes, I want to point to a server path that the application references.
Top Expert 2014

if you know at least one of the files in the directory, you could iterate the mapped drives (via FSO object) and look for this file.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.