471,306 Members | 1,207 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

Detecting bin\debug versus bin\release?

How can an app detect whether its running under debug or release mode and update file paths automatically?
I have several hardcoded paths like "c:\app\bin\debug" currently and want to make it more robust.

Thanks!

Adam

Feb 20 '06 #1
3 2071
Why are you hardcoding the paths to begin with?

If you need to detect that, I would imaging that you could use the #if DEBUG and set a variable according to what you are running in.

"AdamM" <no****@nospam.com> wrote in message news:zO********************@comcast.com...
How can an app detect whether its running under debug or release mode and update file paths automatically?
I have several hardcoded paths like "c:\app\bin\debug" currently and want to make it more robust.

Thanks!

Adam

Feb 20 '06 #2
AdamM wrote:
How can an app detect whether its running under debug or release mode
and update file paths automatically?
I have several hardcoded paths like "c:\app\bin\debug" currently and
want to make it more robust.

Thanks!

Adam

Hi Adam,

use Application.StartupPath to determine the directory. Now there are
two ways (Well, actually there are some more :-) ) to handle the paths:

->Make all you hardcoded paths relative to your application directory,
e.g.: ..\..\Data. Use Path.Combine to build a valid Path when you need it.

string path =
Path.GetFullPath(Path.Combine(
Application.StartupPath, @"..\..\Data")
);

->store all you data under thhe current or the all user profile. You can
get the path like this:

string curUserProfile =
Environment.GetFolderPath(Environment.SpecialFolde r.ApplicationData);
string allUserProfile =
Environment.GetFolderPath(Environment.SpecialFolde r.CommonApplicationData);
You might want to evaluate to use the isolated storage mechanims, too.

HTH,
Andy

--
To email me directly, please remove the *NO*SPAM* parts below:
*NO*SPAM*xmen40@*NO*SPAM*gmx.net
Feb 20 '06 #3

"AdamM" <no****@nospam.com> wrote in message
news:zO********************@comcast.com...
How can an app detect whether its running under debug or release mode and
update file paths automatically?
I have several hardcoded paths like "c:\app\bin\debug" currently and want to
make it more robust.

Don't do it.

When you release the app to users it will be running under somewhere else
entirely whether it is the debug or the release version.

Use stuff like Application.StartupPath and Environment.SpecialFolder... to
get directories and #if DEBUG or better yet [ConditionalAttribute("DEBUG")]
to perform do debug/release specific stuff or filenames.
Feb 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Jole | last post: by
15 posts views Thread by Jay | last post: by
3 posts views Thread by raptor | last post: by
6 posts views Thread by Querejeto | last post: by
9 posts views Thread by D. Shane Fowlkes | last post: by
27 posts views Thread by Deek | last post: by
3 posts views Thread by regtrashcan | last post: by
13 posts views Thread by John W. | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.