console application path

Posted on 2006-04-05
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?
Question by:arichexe
    LVL 10

    Accepted Solution



    LVL 48

    Expert Comment

    string aPath1 = Application.ExecutablePath;
        string aPath2 = Application.StartupPath
    LVL 5

    Expert Comment

    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
    LVL 5

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now