473,554 Members | 2,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\deb ug" currently and want to make it more robust.

Thanks!

Adam

Feb 20 '06 #1
3 2149
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******** ************@co mcast.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\deb ug" 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\deb ug" currently and
want to make it more robust.

Thanks!

Adam

Hi Adam,

use Application.Sta rtupPath 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.GetFullPat h(Path.Combine(
Application.Sta rtupPath, @"..\..\Data ")
);

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

string curUserProfile =
Environment.Get FolderPath(Envi ronment.Special Folder.Applicat ionData);
string allUserProfile =
Environment.Get FolderPath(Envi ronment.Special Folder.CommonAp plicationData);
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.n et
Feb 20 '06 #3

"AdamM" <no****@nospam. com> wrote in message
news:zO******** ************@co mcast.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\deb ug" 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.Sta rtupPath and Environment.Spe cialFolder... to
get directories and #if DEBUG or better yet [ConditionalAttr ibute("DEBUG")]
to perform do debug/release specific stuff or filenames.
Feb 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
12506
by: Jole | last post by:
Hi I'm writing a program that needs to read from a file. In order for the program to be robust, it should somehow check that the file isn't corrupt, or stuffed in any way. For example, that file may have been created but a crash occurred at that point in time (while it was being created), damaging the file. Now, my program which needs to...
15
2680
by: Jay | last post by:
I'm sure this is a really dumb question, but how do you detect a variable type in Python? For example, I want to know if the variable "a" is a list of strings or a single string. How do I do this?
3
1848
by: raptor | last post by:
hi, how to detect opera..it seems that even opera8 doesnt support xmlhttp fully (.i.e. sendRequestHeader). I ask this 'cause opera seems to mimic IE, at least in the preferences ?! I havent used opera till now, but it seems very buggy piece of software !! I have one very annoyng problem, fighting already ~4 hours. I found that if I use...
6
1864
by: Querejeto | last post by:
Hello: Is it possible to detect programmatically the constness of a member function when it is called? That is, I would like to see a generic implementation (i.e. it does not depend on the class Base) of the createInstance function below that produces the output: Output:
9
2007
by: D. Shane Fowlkes | last post by:
I'm using SQL Server 2000 and on my page, I'm simply creating a SQLDataReader and filling in Labels with the retrieved (single) record. However, how can I prevent from getting errors when a field is null? I've tried something like this (experimenting with IsDBNull): ========================================================= If...
27
1977
by: Deek | last post by:
I have a target(graphic) that moves via, i am trying to detect a hit of the target with and essay(copied below) my prof gave us, but I am not sure what to do, if you could get me going in the right direction i would appreaciate it: Private Sub tmrTarget_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmrTarget.Tick 'Move...
3
3604
by: regtrashcan | last post by:
I have a webpage that detects whether Shockwave Player is installed and the version number. The javascript/vbscript that I use has worked fine until the latest release of the Shockwave Player. I am still able to detect the Shockwave Player and the version number when using Firefox/Netscape, but not with IE. I have my own detection script that...
79
3721
by: VK | last post by:
I wandering about the common proctice of some UA's producers to spoof the UA string to pretend to be another browser (most often IE). Shouldn't it be considered as a trademark violation of the relevant name owner? If I make a whisky and call it "Jack Daniels", I most probably will have some serious legal problems. "Mozilla" partially...
2
2317
by: petermichaux | last post by:
Hi, I don't know if there is a way to feature detect for this or not. I have a list and the user can click on items to select. I would like that they can command-click on Mac or control-click on other OS to multiple select. This matches normal file system behavior. I found this example which doesn't seem to work in Opera on Mac: the mac...
13
1480
by: John W. | last post by:
Hi there, Does anyone know if there's a (simple) way to detect whether an arbitrary "System.Type" originates from the .NET framework opposed to a user-defined assembly. Thanks.
0
7600
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7889
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6145
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5436
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2020
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1134
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
841
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.