How to get .exe file version number from file path

NoviceMe picture NoviceMe · Jul 5, 2012 · Viewed 87.6k times · Source

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 the version number of demo.exe is 1.0.

How can i use this path to grab version number?.

Answer

Reed Copsey picture Reed Copsey · Jul 5, 2012

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