Retrieve Version Information of a File on disk

The Blog demonstrate, a way to obtain the Version Information or Properties of a Physical File (.exe or .dll etc.) on a disk.

Description:
About Classes used –
#1: An object of FileVersionInfoclass Provides version information for a physical file on disk.
#2: The Information retrieved from object of FileVersionInfoclass 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:
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.
Regards,
Mayur Dighe
http://ImmortalDotNet.blogspot.com
http://MayurDighe.wordpress.com