PDA

Click to See Complete Forum and Search --> : [RESOLVED] Deployment Path different from debugging path


heatgutsexe
Jul 15th, 2008, 10:06 PM
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.

petevick
Jul 16th, 2008, 04:05 AM
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.

heatgutsexe
Jul 16th, 2008, 10:31 PM
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

petevick
Jul 17th, 2008, 01:18 AM
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.

heatgutsexe
Jul 17th, 2008, 07:30 AM
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...

petevick
Jul 17th, 2008, 07:47 AM
you mean you want to get the path of the executable you are running?
AppPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase )