
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
744
|
Chapter 12: Filesystem I/O
Discussion
Not all executable modules have version information. If you load a module with no
version information using the
FileVersionInfo class, you will not provoke an excep-
tion, nor will you get
null back for the object reference. Instead, you will get a valid
FileVersionInfo object with all data members in their initial state (which is null for
.NET objects).
Assemblies actually have two sets of version information: the version information
available in the assembly manifest and the PE (Portable Executable) file version infor-
mation.
FileVersionInfo reads the assembly manifest version information.
The first action this method takes is to determine whether the two files passed in to
the
file1 and file2 parameters actually exist. If so, the static GetVersionInfo method
of the
FileVersionInfo class is called to get version information for the two files.
The
CompareFileVersions method attempts to compare each portion of the file’s ver-
sion number using the following properties of the
FileVersionInfo object returned
by
GetVersionInfo:
FileMajorPart
The first 2 bytes of the version number
FileMinorPart
The second 2 bytes of the version number
FileBuildPart
The third 2 bytes of the version number
FilePrivatePart
The final 2 bytes of the version number
The full version ...