FileVersionInfo::GetVersionInfo Method (String^)
Returns a FileVersionInfo representing the version information associated with the specified file.
Assembly: System (in System.dll)
Parameters
- fileName
-
Type:
System::String^
The fully qualified path and name of the file to retrieve the version information for.
Return Value
Type: System.Diagnostics::FileVersionInfo^A FileVersionInfo containing information about the file. If the file did not contain version information, the FileVersionInfo contains only the name of the file requested.
| Exception | Condition |
|---|---|
| FileNotFoundException | The file specified cannot be found. |
The following example calls GetVersionInfo to get the FileVersionInfo for Notepad and displays the file description and version number in the console window.
#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(); }
to get the version information. Associated enumeration: FileIOPermissionAccess::Read
for full trust for the immediate caller. This class cannot be used by partially trusted code.
Available since 1.1
SpecialBuild
ProductVersion
ProductPrivatePart
ProductName
ProductMinorPart
ProductMajorPart
ProductBuildPart
PrivateBuild
OriginalFilename
LegalTrademarks
LegalCopyright
IsSpecialBuild
IsPreRelease
IsPrivateBuild
IsPatched
IsDebug
InternalName
FileVersion
FilePrivatePart
FileName
FileMinorPart
FileMajorPart
FileDescription
FileBuildPart
CompanyName
Comments
FileVersionInfo Class
System.Diagnostics Namespace