Results 1 to 8 of 8

Thread: Path location

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Path location

    I have files in this location
    Code:
    ShellExecAndWait "C:\PF\Modeling\Precision Farming.mxd", True, frmMenu
    When I used messagebox like this MsgBox App.Path, It pop up the messagebox like this like this C:\PF\GUI . I don't want the location dependency to run this Mxd files. How to do that? My exe program in this location C:\PF\GUI

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Path location

    Are you running this from the IDE or from a compiled EXE?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Path location

    I run from Microsoft project. I will later deploy my program so I don't want my program dependency with the path location to avoid error message. So How to make the program able to run in any directory?

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Path location

    It can run in any directory, but it must know where this file is.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Path location

    If I retain this path location, So during installation, I have to choose the directory I want to install the program, So If I change this directory to other directory during installation, for example in "C:\Project\, which directory the this link will deploy to? in C:\Project\ or in this C:\PF\Modeling
    File10=@Precision Farming.mxd,C:\PF\Modeling,,,1/25/08 11:22:50 AM,7176192,0.0.0.0
    Attached Images Attached Images  

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Path location

    I guess I'm not understanding the problem.

    So, the user changes directories when they install it. You aren't hard coding any paths. If you App.Path, then your program should find it, unless, after installtion, the user physically moves the file and that is something over which you have no control.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Re: Path location

    Code:
    File10=@Precision Farming.mxd,C:\PF\Modeling,,,1/25/08 11:22:50 AM,7176192,0.0.0.0
    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

  8. #8
    Addicted Member
    Join Date
    Jul 2007
    Posts
    146

    Re: Path location

    Quote 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:
    1. 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:
    1. Dim DatabasePath as String
    2.  
    3. If Len(App.Path) = 3 then
    4.    DatabasePath = App.Path & "Modeling\Precision Farming.mxd"
    5. Else
    6.    DatabasePath = App.Path & "\Modeling\Precision Farming.mxd"
    7. Endif
    8.  
    9. ' Or even better...
    10.  
    11. If mid$(App.Path, Len(App.Path), 1) = "\" then
    12.    DatabasePath = App.Path & "Modeling\Precision Farming.mxd"
    13. Else
    14.    DatabasePath = App.Path & "\Modeling\Precision Farming.mxd"
    15. 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
  •  



Click Here to Expand Forum to Full Width