?
Solved

console application path

Posted on 2006-04-05
4
Medium Priority
?
1,336 Views
Last Modified: 2008-01-09
How would I get the path of a console application?  Request.ServerVariables["APPL_PHYSICAL_PATH"].ToString() works for a web app, but how about for a console app?
0
Comment
Question by:arichexe
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
smegghead earned 200 total points
ID: 16385575
use

System.IO.Directory.GetCurrentDirectory()

0
 
LVL 48

Expert Comment

by:Mikal613
ID: 16385576
string aPath1 = Application.ExecutablePath;
    string aPath2 = Application.StartupPath
0
 
LVL 5

Expert Comment

by:ennixo
ID: 16386409
1. Add a reference to System.Windows.Forms
2. Add a using System.Windows.Forms; statement
3. The path you need is in Application.StartupPath property
0
 
LVL 5

Expert Comment

by:ennixo
ID: 16387725
Bad choice...

create a shortcut to your executable, edit the properties of this shortcut to change the startup path and then run your program : GetCurrentDirectory won't return the good path.

It may also return a wrong path if you access to files and change the current directory (ie: with SetCurrentDirectory) and then call GetCurrentDirectory.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question