How to get .exe file version number from file path

前端 未结 7 1924
猫巷女王i
猫巷女王i 2020-12-08 06:16

I am using .Net 3.5/4.0 with code in C#.

I am trying to get a version number of an exe file on my C: drive.

For example path is: c:\\Program\\demo.exe. If t

7条回答
  •  春和景丽
    2020-12-08 06:41

    You can use FileVersionInfo.FileVersion to fetch this from a path.

    var versionInfo = FileVersionInfo.GetVersionInfo(pathToExe);
    string version = versionInfo.FileVersion; // Will typically return "1.0.0.0" in your case
    

提交回复
热议问题