FileVersionInfo Class

Provides version information for a physical file on disk.

System::Object
  System.Diagnostics::FileVersionInfo

Namespace:  System.Diagnostics
Assembly:  System (in System.dll)

[PermissionSetAttribute(SecurityAction::LinkDemand, Name = L"FullTrust")]
public ref class FileVersionInfo sealed

The FileVersionInfo type exposes the following members.

  NameDescription
Public propertyCommentsGets the comments associated with the file.
Public propertyCompanyNameGets the name of the company that produced the file.
Public propertyFileBuildPartGets the build number of the file.
Public propertyFileDescriptionGets the description of the file.
Public propertyFileMajorPartGets the major part of the version number.
Public propertyFileMinorPartGets the minor part of the version number of the file.
Public propertyFileNameGets the name of the file that this instance of FileVersionInfo describes.
Public propertyFilePrivatePartGets the file private part number.
Public propertyFileVersionGets the file version number.
Public propertyInternalNameGets the internal name of the file, if one exists.
Public propertyIsDebugGets a value that specifies whether the file contains debugging information or is compiled with debugging features enabled.
Public propertyIsPatchedGets a value that specifies whether the file has been modified and is not identical to the original shipping file of the same version number.
Public propertyIsPreReleaseGets a value that specifies whether the file is a development version, rather than a commercially released product.
Public propertyIsPrivateBuildGets a value that specifies whether the file was built using standard release procedures.
Public propertyIsSpecialBuildGets a value that specifies whether the file is a special build.
Public propertyLanguageGets the default language string for the version info block.
Public propertyLegalCopyrightGets all copyright notices that apply to the specified file.
Public propertyLegalTrademarksGets the trademarks and registered trademarks that apply to the file.
Public propertyOriginalFilenameGets the name the file was created with.
Public propertyPrivateBuildGets information about a private version of the file.
Public propertyProductBuildPartGets the build number of the product this file is associated with.
Public propertyProductMajorPartGets the major part of the version number for the product this file is associated with.
Public propertyProductMinorPartGets the minor part of the version number for the product the file is associated with.
Public propertyProductNameGets the name of the product this file is distributed with.
Public propertyProductPrivatePartGets the private part number of the product this file is associated with.
Public propertyProductVersionGets the version of the product this file is distributed with.
Public propertySpecialBuildGets the special build information for the file.
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberGetVersionInfoReturns a FileVersionInfo representing the version information associated with the specified file.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a partial list of properties in the FileVersionInfo and their values. (Overrides Object::ToString().)
Top

Typically, a version number is displayed as "major number.minor number.build number.private part number". A file version number is a 64-bit number that holds the version number for a file as follows:

Use the GetVersionInfo method of this class to get a FileVersionInfo containing information about a file, then look at the properties for information about the file. The FileVersion property provides version information about the file. The ProductMajorPart, ProductMinorPart, ProductBuildPart, ProductPrivatePart, and ProductVersion properties provide version information for the product that the specified file is a part of. Call ToString to get a partial list of properties and their values for this file.

The FileVersionInfo properties are based on version resource information built into the file. Version resources are often built into binary files such as .exe or .dll files; text files do not have version resource information.

Version resources are typically specified in a Win32 resource file, or in assembly attributes. For example the IsDebug property reflects the VS_FF_DEBUG flag value in the file's VS_FIXEDFILEINFO block, which is built from the VERSIONINFO resource in a Win32 resource file. For more information about specifying version resources in a Win32 resource file, see "About Resource Files" and "VERSIONINFO Resource" in the Platform SDK. For more information about specifying version resources in a .NET module, see the Setting Assembly Attributes topic.

NoteNote

This class makes a link demand at the class level that applies to all members. A SecurityException is thrown when the immediate caller does not have full trust permission. For details about link demands, see Link Demands.

The following example calls GetVersionInfo to get the FileVersionInfo for the Notepad. Then it prints the file description and version number in a text box. This code assumes textBox1 has been instantiated.


#using <System.dll>

using namespace System;
using namespace System::IO;
using namespace System::Diagnostics;


public ref class Class1
{

public:
    static void Main()
    {
        // Get the file version for the notepad.
        // Use either of the two following methods.
        FileVersionInfo::GetVersionInfo(Path::Combine(Environment::SystemDirectory, "Notepad.exe"));
        FileVersionInfo^ myFileVersionInfo = FileVersionInfo::GetVersionInfo(Environment::SystemDirectory + "\\Notepad.exe");


        // Print the file name and version number.
        Console::WriteLine("File: " + myFileVersionInfo->FileDescription + "\n" +
           "Version number: " + myFileVersionInfo->FileVersion);
    }
};

int main()
{
    Class1::Main();
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft