[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.
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.
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
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.
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...
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)