I have this problem of moving my codes around in my external drive. Everytime I plug the external drive to a new PC, a different drive is assigned and I would have path not found error in my program. I only knew about set_path=app.path which is actually referring to the path where VB6 is installed and not directory of the VB project file that I saved in. Is there any any to set the path to the local path of .vbp or .frm?

Dani AI

Generated

Quick clarification for : App.Path returns the folder of the running program. When you run inside the VB6 IDE (F5) the running process is VB6.EXE, so App.Path often shows the VB6 install folder — that is why you saw the VB path. and were on the right track about App.Path reflecting the application's location at runtime, but the IDE changes what the running application actually is.

Practical fixes (pick one that fits your workflow):

  • Ship and run a compiled EXE on the external drive and build file paths relative to that EXE (this is the most robust for removable media).
  • Keep data/resources in a subfolder next to the EXE and always construct paths relative to the application folder (see helper below).
  • If the file must live on a network share, use a UNC path (\server\share...) and split your Access database into front-end/back-end for multi-user access. Do not rely on drive letters for network or removable drives.
  • If you cannot rely on relative layout, place a small unique marker file (or known folder name) at the root of the external drive and scan drives at startup until you find it. Use Dir or the FileSystemObject (add reference to "Microsoft Scripting Runtime") — but be aware scanning all drives can be slow and you should skip drives that are not ready.

Safe helper to build a reliable application-folder path (handles trailing backslash):

Function AppFolder() As String
    Dim s As String
    s = App.Path
    If Right$(s, 1) <> "\" Then s = s & "\"
    AppFolder = s
End Function

' Usage:
' dataFile = AppFolder() & "data\mydatafile.dat"

Note: for and others using Access on a network — keep the .mdb/.accdb on a shared UNC path, split the DB, and let each user run their own front-end from their workstation (or the external drive) to avoid locking and path issues.

Recommended Answers

All 3 Replies

App.Path is return path of your program.
It will return path where the project is saved.
Just take a test. Create a new project and display a path of project (Msgbox App.Path) in form load event and save it. It will return path of project. Move the project to another directory and run it again, the part will changed for sure.

app.path which is actually referring to the path where VB6 is installed

it doesn't return the path where vb6 is installed but it returns the path of the project where it is saved.

there are probably two reasons
1. may be you're using default vb6 path for saving files. Thats why you are saying so . . .
2. other reason is that you used App.Path before saving the project

so finally create a small project and then save it to different drive or directory and then use it.And you will understand the concept of App.Path

hope this helps you . . .

hi , I have a problem to set path of ms-access file in network in vb application. How to set a network path for a database in vb 6.0 so multiple users can work in same database ?
Pls. help me....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.