Results 1 to 3 of 3

Thread: Finding Install Directory

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2004
    Location
    The Netherlands
    Posts
    37

    Finding Install Directory

    How can I find the directory my program was installed to?

    Let's say a user installed it in C:\MyApp
    My program then puts the Excel files is uses in there aswell.

    C:\MyApp\MyApp.exe
    C:\MyApp\MyExcelFile1.xls
    C:\MyApp\MyExcelFile2.xls

    I'm reading the .xls files from MyApp.exe so I'ld like to know the location of the .xls files.

    To do this I've found: Application.StartupPath
    but when a user copies my application to run from somewhere else the startuppath doesn't help me finding my .xls files, they are still where the application was installed.

    Anyone?

  2. #2
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    I don't know how, but I know that you can make a registry key during setup.
    Then your program could read that key.

    But it shouldn't even be an issue, IMHO. Users aren't supposed to move files around like that. Try moving Excel.exe or any other exe file without moving the rest of the app. It'd probably crash.

    If the user needs the app to be in another directory they should uninstall and reinstall in another location.

    At least, that's just my 2 cents.
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  3. #3
    Lively Member
    Join Date
    Jun 2004
    Posts
    74
    You could write a recursive function to find a particular file name using the DIR command or the file system object. Then run this on the known file names if they are not found in the Application.StartupPath location.

    HTH

    Hume

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