FileVersionInfo FileVersionInfo FileVersionInfo FileVersionInfo Class

Definition

Provides version information for a physical file on disk.

public ref class FileVersionInfo sealed
public sealed class FileVersionInfo
type FileVersionInfo = class
Public NotInheritable Class FileVersionInfo
Inheritance
FileVersionInfoFileVersionInfoFileVersionInfoFileVersionInfo

Examples

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();
}

using System;
using System.IO;
using System.Diagnostics;

class Class1
{
    public static void Main(string[] args)
    {
        // Get the file version for the notepad.
        // Use either of the two following commands.
        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);
    }

}
Imports System.IO
Imports System.Diagnostics



Class Class1

    Public Shared Sub Main(ByVal args() As String)
        ' Get the file version for the notepad.
        ' Use either of the following two commands.
        FileVersionInfo.GetVersionInfo(Path.Combine(Environment.SystemDirectory, "Notepad.exe"))
        Dim myFileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + "\Notepad.exe")


        ' Print the file name and version number.
        Console.WriteLine("File: " + myFileVersionInfo.FileDescription + vbLf + "Version number: " + myFileVersionInfo.FileVersion)

    End Sub
End Class

Remarks

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.

Note

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.

Properties

Comments Comments Comments Comments

Gets the comments associated with the file.

CompanyName CompanyName CompanyName CompanyName

Gets the name of the company that produced the file.

FileBuildPart FileBuildPart FileBuildPart FileBuildPart

Gets the build number of the file.

FileDescription FileDescription FileDescription FileDescription

Gets the description of the file.

FileMajorPart FileMajorPart FileMajorPart FileMajorPart

Gets the major part of the version number.

FileMinorPart FileMinorPart FileMinorPart FileMinorPart

Gets the minor part of the version number of the file.

FileName FileName FileName FileName

Gets the name of the file that this instance of FileVersionInfo describes.

FilePrivatePart FilePrivatePart FilePrivatePart FilePrivatePart

Gets the file private part number.

FileVersion FileVersion FileVersion FileVersion

Gets the file version number.

InternalName InternalName InternalName InternalName

Gets the internal name of the file, if one exists.

IsDebug IsDebug IsDebug IsDebug

Gets a value that specifies whether the file contains debugging information or is compiled with debugging features enabled.

IsPatched IsPatched IsPatched IsPatched

Gets a value that specifies whether the file has been modified and is not identical to the original shipping file of the same version number.

IsPreRelease IsPreRelease IsPreRelease IsPreRelease

Gets a value that specifies whether the file is a development version, rather than a commercially released product.

IsPrivateBuild IsPrivateBuild IsPrivateBuild IsPrivateBuild

Gets a value that specifies whether the file was built using standard release procedures.

IsSpecialBuild IsSpecialBuild IsSpecialBuild IsSpecialBuild

Gets a value that specifies whether the file is a special build.

Language Language Language Language

Gets the default language string for the version info block.

LegalCopyright LegalCopyright LegalCopyright LegalCopyright

Gets all copyright notices that apply to the specified file.

LegalTrademarks LegalTrademarks LegalTrademarks LegalTrademarks

Gets the trademarks and registered trademarks that apply to the file.

OriginalFilename OriginalFilename OriginalFilename OriginalFilename

Gets the name the file was created with.

PrivateBuild PrivateBuild PrivateBuild PrivateBuild

Gets information about a private version of the file.

ProductBuildPart ProductBuildPart ProductBuildPart ProductBuildPart

Gets the build number of the product this file is associated with.

ProductMajorPart ProductMajorPart ProductMajorPart ProductMajorPart

Gets the major part of the version number for the product this file is associated with.

ProductMinorPart ProductMinorPart ProductMinorPart ProductMinorPart

Gets the minor part of the version number for the product the file is associated with.

ProductName ProductName ProductName ProductName

Gets the name of the product this file is distributed with.

ProductPrivatePart ProductPrivatePart ProductPrivatePart ProductPrivatePart

Gets the private part number of the product this file is associated with.

ProductVersion ProductVersion ProductVersion ProductVersion

Gets the version of the product this file is distributed with.

SpecialBuild SpecialBuild SpecialBuild SpecialBuild

Gets the special build information for the file.

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetVersionInfo(String) GetVersionInfo(String) GetVersionInfo(String) GetVersionInfo(String)

Returns a FileVersionInfo representing the version information associated with the specified file.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a partial list of properties in the FileVersionInfo and their values.

Security

LinkDemand
for full trust for the immediate caller. This class cannot be used by partially trusted code.

Applies to

See also