I know how to get the version of an executing application or dll. However I need to find the properties of a non executing application.
I have a small program to set a file association for my main application. There is no point in users of old versions running this since the application does not accept arguments on start up. So when the file associator starts it first checks to see if it can find the main app. If it can then I want to check the properties without executing it. If the version is earlier than one that can accept arguments then I want to tell my user to update rather than proceed to set the association.
I have looked at System.IO.FileInfo but that does not seem to include any Version information.
Thanks
For example, Oracle Java has the java.exe file, CCleaner has ccleaner.exe and so on. Right click on it and then select Properties. In the Properties window, go to the Details tab. There you will find information about the product name, the product version and so on.
For a file that is missing version info completely: After opening the DLL in Visual Studio, go to Edit > Add Resource > Version and click New. Then in the new Version tab, change FILEVERSION and PRODUCTVERSION, CompanyName, etc. Save the files and you're all set!
A .exe is a binary code, unless its instrumented with source code for debugging its close to impossible to get the source code.
You can use FileVersionInfo.GetVersionInfo()
:
FileVersionInfo vi = FileVersionInfo.GetVersionInfo("myfile.dll");
string showVersion = vi.FileVersion;
//showVersion is the actual version No.
This returns file/document metadata and can be used for unmanaged DLLs or even word documents as well.
You can also use Assembly:
Version v = Assembly.ReflectionOnlyLoadFrom("myfile.dll").GetName().Version;
This will contain .NET version information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With