path to the executable


Another one that I
have seen come up before…


Q: How to find that path to the
executable I am running in?


A:
Assembly.GetExecutingAssembly().Location

Comments (2)

  1. Matt Berther says:

    Yes and no… 🙂

    Technically, the answer would be…

    Path.GetDirectoryName(
    Assembly.GetExecutingAssembly().Location);

    Now, I think this may only work if the files arent shadow copied (most ASP.NET applications). If they are shadow copied, you will need to use Assembly.GetExecutingAssembly().CodeBase.

  2. Phil Weber says:

    Also: System.Windows.Forms.Application.StartupPath