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]
.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
System.AppDomain.CurrentDomain.FriendlyName
- Returns the filename with extension (e.g. MyApp.exe).System.Diagnostics.Process.GetCurrentProcess().ProcessName
- Returns the filename without extension (e.g. MyApp).System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
- Returns the full path and filename (e.g. C:\Examples\Processes\MyApp.exe). You could then pass this intoSystem.IO.Path.GetFileName()
orSystem.IO.Path.GetFileNameWithoutExtension()
to achieve the same results as the above.Couple more options:
System.Reflection.Assembly.GetExecutingAssembly().GetName().Name
Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase
Why nobody suggested this, its simple.
This is the code which worked for me:
All the examples above gave me the processName with vshost or the running dll name.
This works if you need only the Application name without extensio:
This should suffice: