How do I get the name of the current executable in

2019-01-04 18:32发布

I want to get the name of the currently running program, that is the executable name of the program. In C/C++ you get it from args[0].

20条回答
一夜七次
2楼-- · 2019-01-04 19:08

Try this:

System.Reflection.Assembly.GetExecutingAssembly()

This returns you a System.Reflection.Assembly instance that has all the data you could ever want to know about the current application. I think that the Location property might get what you are after specifically.

查看更多
smile是对你的礼貌
3楼-- · 2019-01-04 19:10
  • System.Reflection.Assembly.GetEntryAssembly().Location returns location of exe name if assembly is not loaded from memory.
  • System.Reflection.Assembly.GetEntryAssembly().CodeBase returns location as URL.
查看更多
登录 后发表回答