473,383 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Determine whether App is running is Visual Studio

Is there a way to do:

#if APP_IS_RUN_IN_VS
path = ".\..\..\..\myfile.rpt";
#else
path = "myfile.rpt";
#endif

I don't want to put the files into debug/bin dir since they woulbe be
deleted on rebuilt then.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #1
14 2364
If we assume that you always use the Debug configuration to run the project
from the IDE,
you can use the following condition:

#if DEBUG
path = ".\..\..\..\myfile.rpt";
#else
path = "myfile.rpt";
#endif

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"cody" <no****************@gmx.net> wrote in message
news:uG*************@TK2MSFTNGP12.phx.gbl...
Is there a way to do:

#if APP_IS_RUN_IN_VS
path = ".\..\..\..\myfile.rpt";
#else
path = "myfile.rpt";
#endif

I don't want to put the files into debug/bin dir since they woulbe be
deleted on rebuilt then.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk


Nov 16 '05 #2
You can use this:

Public Shared Function IsInIDE() As Boolean

If System.Diagnostics.Debugger.IsAttached Then

'The application is currently running from within the IDE.

Return True

Else

'The application is currently running as a compiled application.

Return False

End If

End Function
--

HTH

Éric Moreau, MCSD
Conseiller Principal / Senior Consultant
Concept S2i inc.(www.s2i.com)
"cody" <no****************@gmx.net> wrote in message
news:uG*************@TK2MSFTNGP12.phx.gbl...
Is there a way to do:

#if APP_IS_RUN_IN_VS
path = ".\..\..\..\myfile.rpt";
#else
path = "myfile.rpt";
#endif

I don't want to put the files into debug/bin dir since they woulbe be
deleted on rebuilt then.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk

Nov 16 '05 #3
> If we assume that you always use the Debug configuration to run the
project
from the IDE,
you can use the following condition:

#if DEBUG
path = ".\..\..\..\myfile.rpt";
#else
path = "myfile.rpt";
#endif

But I cannot assume this. Additionally, Debug is still set if the app is not
run in VS. Is there another way?
Maybe I can instruct VS to automatically copy these files into the bin/obj
dirs so there is no need to change the path, but how?

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #4
> You can use this:

Public Shared Function IsInIDE() As Boolean

If System.Diagnostics.Debugger.IsAttached Then

'The application is currently running from within the IDE.

Return True

Else

'The application is currently running as a compiled application.

Return False

End If

End Function

Thank you, but what if I start the app in VS without debug?
What would you do if you have a file that your application needs to open and
you don't want it to copy in the bin/obj directory every time manually?
There must be a way!

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #5
BTW - are you that sure that the whole contents of the Debug folder is
erased every time the project is built? I remember I copied necessary data
files to bin\Debug rather frequently and they remained intact regardless of
many subsequent builds...

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"cody" <no****************@gmx.net> wrote in message
news:Oa**************@TK2MSFTNGP10.phx.gbl...
You can use this:

Public Shared Function IsInIDE() As Boolean

If System.Diagnostics.Debugger.IsAttached Then

'The application is currently running from within the IDE.

Return True

Else

'The application is currently running as a compiled application.

Return False

End If

End Function

Thank you, but what if I start the app in VS without debug?
What would you do if you have a file that your application needs to open

and you don't want it to copy in the bin/obj directory every time manually?
There must be a way!

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk


Nov 16 '05 #6
> BTW - are you that sure that the whole contents of the Debug folder is
erased every time the project is built? I remember I copied necessary data
files to bin\Debug rather frequently and they remained intact regardless of many subsequent builds...

VS clears that folder if you do a complete rebuild. regular builds don't do
this.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #7
Just out of interest, why not just place your files in a directory elsewhere
on the hd and just reference it from there? Or even place them in your
project directory (up from debug) and reference it using "..\filename"?

Kieran

"cody" <no****************@gmx.net> wrote in message
news:uu**************@TK2MSFTNGP09.phx.gbl...
BTW - are you that sure that the whole contents of the Debug folder is
erased every time the project is built? I remember I copied necessary data files to bin\Debug rather frequently and they remained intact regardless of
many subsequent builds...

VS clears that folder if you do a complete rebuild. regular builds don't

do this.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk

Nov 16 '05 #8
> Just out of interest, why not just place your files in a directory
elsewhere
on the hd and just reference it from there? Or even place them in your
project directory (up from debug) and reference it using "..\filename"?

Sure I could do this and all would be fine if I run my program from Visual
studio.
But sometimes I need to deploy my app and I do not want to have a path in
the
following form "c:\cody\projects\myapp" or "..\..\myfile.rpt", since my
customer
will neither have Visual Studio installed nor does he have a directory named
"c:\cody\projects".

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #9
There are ways to bypass this problem.
You could use Application.StartupPath and make a sub directory for the
file.
You can put the file under the local user in Documents and Settings using
Application.LocalUserAppDataPath.
You can use a registry entry or a config file specifying the location of
the file.

Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #10
> There are ways to bypass this problem.
You could use Application.StartupPath and make a sub directory for the
file.
You can put the file under the local user in Documents and Settings using
Application.LocalUserAppDataPath.
You can use a registry entry or a config file specifying the location of
the file.

I wanted the files to be in the same directory where the executable file is.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #11
Application.StartupPath then

Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #12
> Application.StartupPath then

this gets me:

D:\cody\projects\myapp\MainWindow\bin\Debug

But I don't want to put the files into the "bin\Debug" since VS sometimes
erases it.
I thought on including the files as resource. I embedded the files into my
project and set the type on "embedded resource". So now the big question is
how to load them.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #13
cody wrote:
[...]
But I don't want to put the files into the "bin\Debug" since VS sometimes
erases it. [...]


I just tried creating a new text file in 'bin\Debug' then rebuilding the
solution multiple times, and the file wasn't deleted. I'm using VS.NET
2003...
Nov 16 '05 #14
> > But I don't want to put the files into the "bin\Debug" since VS
sometimes
erases it. [...]


I just tried creating a new text file in 'bin\Debug' then rebuilding the
solution multiple times, and the file wasn't deleted. I'm using VS.NET
2003...


I also tried it now and it didn't disappear either. I could swear VS would
clear the bin/obj folder on complete rebuilds.
Maybe it was in another version, maybe it was C++. :(
Thanks, this should have solved my problem for now :)

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
Nov 16 '05 #15

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

Similar topics

16
by: Donjuan | last post by:
Hi all I have trouble with tracking whether my image file is loaded. i use DHTML to change my image. HERE is the code: <img name="someimage" src="1.jpg"...
18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
5
by: Dafna | last post by:
while trying to open an Asp .Net application ' I get the following message (the IIS on my computer is running) "Visual Studio .Net has detected that the specified web server is not running ASP...
2
by: Tyrant Mikey | last post by:
Hi all. I've got some code I've placed in my global.asax file that registers a trace listener. The listener actually makes Debug.Assert statements that fail break into the debugger, which is...
3
by: Rob Nicholson | last post by:
How do you determine if a program is running in the Visual Studio IDE/debugger as opposed to standalone? We often include support files in the same folder as the executable and would so something...
1
by: DR | last post by:
What ports do i need to unblock on client and server (running msvsmon.exe) to debug remotely from my client box with visual studio 2005 pro? When I attach to remote process a connection shows up...
1
by: Cramer | last post by:
I'm running XP Pro/SP2 + patches and updates, with Visual Studio Professional 2008 (and no prior installation of Visual Studio ever installed). When attempting to open an ASP.NET Web application...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.