|
-
Jul 15th, 2008, 10:06 PM
#1
Thread Starter
Member
[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.
-
Jul 16th, 2008, 04:05 AM
#2
Frenzied Member
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.
-
Jul 16th, 2008, 10:31 PM
#3
Thread Starter
Member
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
-
Jul 17th, 2008, 01:18 AM
#4
Frenzied Member
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.
-
Jul 17th, 2008, 07:30 AM
#5
Thread Starter
Member
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...
-
Jul 17th, 2008, 07:47 AM
#6
Frenzied Member
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)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|