Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Retrieve file version information

Total Hit ( 3719)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


The System.Diagnostics.FileVersionInfo class lets you easily read file version information without having to call Windows API functions (as you have to do under previous VB versions). This class has a static GetVersionInfo method that returns a FileVersionInfo object related to a given file. Once you have such an object, retrieving version information is as easy as calling its properties. Here's a code snippet that shows what kind of properties you can query:

Click here to copy the following block
' get information about Microsoft Word
Dim exefile As String = "C:\Program Files\Microsoft Office\Office\Winword.exe"
Dim fvi As FileVersionInfo = FileVersionInfo.GetVersionInfo(exefile)

Console.WriteLine("ProductName: {0}", fvi.ProductName)
Console.WriteLine("ProductVersion: {0}", fvi.ProductVersion)
Console.WriteLine("CompanyName: {0}", fvi.CompanyName)
Console.WriteLine("FileVersion: {0}", fvi.FileVersion)
Console.WriteLine("FileDescription: {0}", fvi.FileDescription)
Console.WriteLine("OriginalFilename: {0}", fvi.OriginalFilename)
Console.WriteLine("LegalCopyright: {0}", fvi.LegalCopyright)
Console.WriteLine("LegalTrademarks: {0}", fvi.LegalTrademarks)
Console.WriteLine("Comments: {0}", fvi.Comments)
Console.WriteLine("InternalName: {0}", fvi.InternalName)

You can also query individual version numbered components with the ProductMajorPart, ProductMinorPart, ProductBuildPart, and ProductPrivatePart (for the product version) and FileMajorPart, FileMinorPart, FileBuildPart, and FilePrivatePart (for the file version) properties. There are also five boolean properties that return additional information about the executable:

Click here to copy the following block
Console.WriteLine("IsDebug: {0}", fvi.IsDebug)
Console.WriteLine("IsPatched: {0}", fvi.IsPatched)
Console.WriteLine("IsPreRelease: {0}", fvi.IsPreRelease)
Console.WriteLine("IsPrivateBuild: {0}", fvi.IsPrivateBuild)
Console.WriteLine("IsSpecialBuild: {0}", fvi.IsSpecialBuild)


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.