Application path

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello All
I'm new to C# and .Net in general and wanted to know if someone could tell me why Application.StartupPath returns the location of .Net runtime files (i.e. C:\WINNT\.....) and not the path of my application

Thanks
Phillip
 
----- Eric Cadwell wrote: ----

Try this

string path = System.Reflection.Assembly.GetExecutingAssembly().Location

O

string path = Application.ExecutablePath

O

string path = Application.StartupPath

HTH
Eric Cadwel
http://www.origincontrols.co


Thanks Eric. Maybe it's something I just don't understand about the IDE. I've tried all of the lines of code you suggested but when working in the IDE the results are still the same. I'm in debug mode and using a break point to examine the value. Is this the problem? Does running the code in debug mode always "obscure" the path values?
 
Doesn't seem to be the case for me. Are you using Windows Forms?

Not sure why you're seeing that.

-Eric
 
I just figured a way around it. It's web app and the code behind instantiates another object. It's within this object that I cannot see the path. So, I used Server.MapPath from the calling code behind class to find the directory and passed that to the child object. It worked, kinda different than what I'm used to, but I'm up an running. Thanks for taking the time to help. I appreciate it man

Phillip
 
Back
Top