Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
742
|
Chapter 12: Filesystem I/O
12.25 Comparing Version Information
of Two Executable Modules
Problem
You need to programmatically compare the version information of two executable
modules. An executable module is a file that contains executable code such as an .exe
or .dll file. The ability to compare the version information of two executable mod-
ules can be very useful to an application in situations such as:
Trying to determine if it has all of the “right” pieces present to execute
Deciding on an assembly to dynamically load through reflection
Looking for the newest version of a file or .dll from many files spread out in the
local filesystem or on a network
Solution
Use the CompareFileVersions method to compare executable module version infor-
mation. This method accepts two filenames, including their paths, as parameters.
The version information of each module is retrieved and compared. This file returns
a
FileComparison enumeration, defined as follows:
public enum FileComparison
{
Same = 0,
Newer = 1, // File1 is newer than File2
Older = 2, // File1 is older than File2
Error = 3
}
The code for the CompareFileVersions method is shown in Example 12-14.
Example 12-14. CompareFileVersions method
public static FileComparison CompareFileVersions(string file1, string file2)
{
FileComparison ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata