FileVersionInfo.GetVersionInfo(String) Metoda

Definicja

Zwraca FileVersionInfo reprezentowanie informacji o wersji skojarzonych z określonym plikiem.Returns a FileVersionInfo representing the version information associated with the specified file.

public:
 static System::Diagnostics::FileVersionInfo ^ GetVersionInfo(System::String ^ fileName);
public static System.Diagnostics.FileVersionInfo GetVersionInfo (string fileName);
static member GetVersionInfo : string -> System.Diagnostics.FileVersionInfo
Public Shared Function GetVersionInfo (fileName As String) As FileVersionInfo

Parametry

fileName
String

W pełni kwalifikowana ścieżka i nazwa pliku, do którego mają zostać pobrane informacje o wersji.The fully qualified path and name of the file to retrieve the version information for.

Zwraca

FileVersionInfo

FileVersionInfoZawierający informacje o pliku.A FileVersionInfo containing information about the file. Jeśli plik nie zawiera informacji o wersji, FileVersionInfo zawiera tylko nazwę żądanego pliku.If the file did not contain version information, the FileVersionInfo contains only the name of the file requested.

Wyjątki

Nie można znaleźć podanego pliku.The file specified cannot be found.

Przykłady

Poniższy przykład wywołuje w GetVersionInfo celu uzyskania FileVersionInfo Notatnika i wyświetla opis pliku oraz numer wersji w oknie konsoli.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();
}

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

Dotyczy

Zobacz też