Results 1 to 6 of 6

Thread: [RESOLVED] Deployment Path different from debugging path

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    44

    Resolved [RESOLVED] Deployment Path different from debugging path

    Hi

    Currently, I'm hard coding the program folder path so I can use it for my database connection string and some other functions. The problem I'm facing is this, when I'm deploying the program for debugging, it deploy to \Program Files\<project name>\. However, if I deploy into a SmartDeviceCab project and I install it on the device, it goes to \Program Files\<cab project name>\

    Question: Is there a way I can make my folder path dynamic in the sense it changes rather than hard coding it? Thanks.

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Deployment Path different from debugging path

    Don't hard code paths - EVER.

    Put them in some sort of configuration file, and load them at run time. If you search the forums for 'config.xml' there is some code for configuration files there.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    44

    Re: Deployment Path different from debugging path

    I'm afraid that's not what I meant.

    You see. The folder of where my application install is different when created into a cab file for actual device and when running from emulator in Visual Studio.

    For Example.

    In emulator debug mode the path is: \Program Files\MyApplication\myapplication.exe

    In device after I create the cab file and install it, the path is: \Program Files\MyCabProjectName\myapplication.exe

    For my database connection string and some other resources, the path is hard coded to absolute because of this problem. I want to find a way to make this dynamic and not absolute path.

    Is there a way for me to solve this? Thanks

  4. #4
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Deployment Path different from debugging path

    My post is still valid - never hard code paths into an application - if you install on a foreign language device for example, 'program files' does not exist.

    I am pretty sure you can change your install path in the cab file setup project.
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2008
    Posts
    44

    Re: Deployment Path different from debugging path

    That is why I need to know, if there is a way to detect where is the current programming running (the .exe file) is located in by the program itself and retrieve the path as a string. If possible that is...

  6. #6
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Deployment Path different from debugging path

    you mean you want to get the path of the executable you are running?
    Code:
    AppPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

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