Finding my main executable's path using Assembly vs AppDomain

后端 未结 5 681
面向向阳花
面向向阳花 2020-12-09 03:21

I\'m a .NET user, and my goal is as simple as finding the absolute path of the directory of my main executing assembly (the EXE file).

I have several candidates:

5条回答
  •  攒了一身酷
    2020-12-09 04:10

    Use System.Linq

    string MainExecutablePath= (System.Diagnostics.Process.GetProcesses().First(P =>P.MainWindowTitle == "MainExecutable'sWindowName")).MainModule.FileName.ToString();
    

提交回复
热议问题