VB6 Directory Path

Posted on 2006-03-21
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
Question by:Gary2397
LVL 66

Accepted Solution

Jim Horn earned 2000 total points
ID: 16248696
(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.
LVL 11

Expert Comment

ID: 16248843
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.

Expert Comment

ID: 16249116
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 11

Expert Comment

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

Author Comment

ID: 16249394
Yes, I want to point to a server path that the application references.
LVL 46

Expert Comment

ID: 16250175
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.

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question