Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. get the executable name witin a console exe

get the executable name witin a console exe

Scheduled Pinned Locked Moved C#
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sasuko
    wrote on last edited by
    #1

    I need to get the .exe name within the same application running... I've tried to use Application.ExecutablePath but the whole Application class doesn't work inside my console application. So how can i do?

    P 1 Reply Last reply
    0
    • S Sasuko

      I need to get the .exe name within the same application running... I've tried to use Application.ExecutablePath but the whole Application class doesn't work inside my console application. So how can i do?

      P Offline
      P Offline
      philip_cole
      wrote on last edited by
      #2

      Hi Sasuko, You can use Reflection to get the file name of the exe file. You have two options: System.Reflection.Assembly.GetExecutingAssembly().Location returns the path to the file the actual code is in. So if you put this line in a class library, it will give you the .dll file. System.Reflection.Assembly.GetEntryAssembly().Location returns the path to the file which was first run to start the application. So whether you put this in your console app, or a class library it references, it will always return the path to the .exe. Hope this helps Philip Cole

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups