VB6 Directory Path

Posted on 2006-03-21
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 65

    Accepted Solution

    (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

    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.
    LVL 2

    Expert Comment

    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
    LVL 11

    Expert Comment

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

    Author Comment

    Yes, I want to point to a server path that the application references.
    LVL 44

    Expert Comment

    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

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    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…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now