PDA

View Full Version : [c#] how to get file version info.


MRMAN
06-12-2006, 11:49 AM
Hello.

I am making a tool to copy new files from folder a to folder b.
If a file exists in the b then i want to compare the version number of the file in a and b and if b is a out of date version then it will copy a to b.

The problem is i don't know how to get the version number.

I can get the mod date and time, Attributes and other stuff but can't work out the version.

Does anyone know how.

Thank you.

rlemon
06-12-2006, 03:38 PM
Microsoft C# Unsafe Code Tutorial
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkUnsafeCodeTutorial.asp

Example 3 shows you how to get that product version. To get a different field change the end of the subBlock string you pass to VerQuryValue.
For example:
change:
string spv = @"\StringFileInfo\" + subBlock[0].ToString("X4") + subBlock[1].ToString("X4") + @"\ProductVersion";

to:
string spv = @"\StringFileInfo\" + subBlock[0].ToString("X4") + subBlock[1].ToString("X4") + @"\CompanyName";

etc...

Available fields are:
"CompanyName"
"FileDescription"
"FileVersion"
"InternalName"
"LegalCopyright"
"OriginalFileName"
"ProductName"
"ProductVersion"

MRMAN
06-12-2006, 04:11 PM
Thank you. Ill give it a whirl