|
-
Feb 11th, 2008, 11:59 AM
#8
Addicted Member
Re: Path location
 Originally Posted by matrik02
Code:
ShellExecAndWait "C:\PF\Modeling\Precision Farming.mxd", True, frmMenu
How to code the link for path location for the directory choose by the user during installation? I want all the files are deploy in the directory choose by the user during installaton. I found that, After I choose the directory, the files Precision Farming.mxd is deploy in this location C:\PF\Modeling, rather then C:\Project.. I run the exe from this directory C:\Project.. . This is C:\Project I create during installation.I want Precision Farming.mxd deploy in my choosen directory so that I can used App.path
The whole idea behind App.Path is to not have the problem you think you have. 
When you reference to a file your program is using, never hard code the path, but use App.Path in stead.
For example, your user changes the path during installation to something entirely different you think it would be. However the directory structure of your program remains the same. So if you have stored your database in a sub folder of where ever your app ended up, App.Path will lead you to it without any problem.
Lets say Modeling is the sub dir and Precision Farming.mxd is the database, you could find it easily like this:
vb Code:
App.Path & "\Modeling\Precision Farming.mxd"
The only problem you could encounter is when the user desides to install in the root dir, which never should be done of course. You can catch that error before it occurs by testing the App.Path string before you use it:
vb Code:
Dim DatabasePath as String
If Len(App.Path) = 3 then
DatabasePath = App.Path & "Modeling\Precision Farming.mxd"
Else
DatabasePath = App.Path & "\Modeling\Precision Farming.mxd"
Endif
' Or even better...
If mid$(App.Path, Len(App.Path), 1) = "\" then
DatabasePath = App.Path & "Modeling\Precision Farming.mxd"
Else
DatabasePath = App.Path & "\Modeling\Precision Farming.mxd"
Endif
HTH
Jottum™
XpVistaControls , (transparent) usercontrols for XP, Vista and 7 with W2K legacy support.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|