using System.Diagnostics; var process = Process.GetCurrentProcess(); // Or whatever method you are using string fullPath = process.MainModule.FileName; //fullPath has the path to exe.
此API有一个陷阱,如果您在32位应用程序中运行此代码,则将无法访问64位应用程序路径,因此您必须将应用程序编译为64位应用程序并运行(项目属性→构建→平台目标→x64)。



