Blog

Version Information of a File on disk

Posted by Mayur Dighe Blogs | Visual C# Sep 02, 2012
The Blog demonstrate, a way to obtain the Version Information or Properties of a Physical File (.exe or .dll etc.) on a disk.
Download Files: VersionInfo.zip

Description

About Classes used

 #1: An object of FileVersionInfo class Provides version information for a physical file on disk.
 
#2: The Information retrieved from object of FileVersionInfo class is READ-ONLY information.
We cannot alter or modify this information.

Namespace Required - System.Diagnostics

Here I implemented the Code for retrieving version information for a physical file on disk.

The Code

1. Put the following code into your program (do necessary changes).  

// txtPath is the Name of TextBox Control
 
// New instance of FileVersionInfo
FileVersionInfo info = FileVersionInfo.GetVersionInfo(txtPath.Text);
 
String Info     "File Name  : " + info.FileName +
                  "InternalName   : " + info.InternalName +
                  "ProductName    : " + info.ProductName +
                        "ProductVersion : " + info.ProductVersion +
                        "OriginalFilename : " + info.OriginalFilename +
                  "LegalTrademarks  : " + info.LegalTrademarks +
                        "LegalCopyright   : " + info.LegalCopyright +
                        "FileDescription  : " + info.FileDescription +
                        "CompanyName        : " + info.CompanyName +
                        "Comments         : " + info.Comments;

Listing 1

2. Now you can pass this string to any label or text control. (Here I used it for a Text Control)

3. Now execute the Application and see the result (Figure 1).

Intended Result:

New Picture (2).png

Figure 1

Summary

In this piece of writing, using C# environment, we have seen how to retrieve version information for a specified physical file from disk.

post comment
     
COMMENT USING
PREMIUM SPONSORS
Over-C is a holistic consortium of communications and technology specialists. We build, deploy and market both business as well as consumer products and solutions.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts