Bagikan melalui


FileVersionInfo.GetVersionInfo(String) Metode

Definisi

Mengembalikan yang FileVersionInfo mewakili informasi versi yang terkait dengan file yang ditentukan.

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

Parameter

fileName
String

Jalur dan nama file yang sepenuhnya memenuhi syarat untuk mengambil informasi versi.

Mengembalikan

Berisi FileVersionInfo informasi tentang file. Jika file tidak berisi informasi versi, FileVersionInfo hanya berisi nama file yang diminta.

Pengecualian

File yang ditentukan tidak dapat ditemukan.

Contoh

Contoh berikut memanggil GetVersionInfo untuk mendapatkan FileVersionInfo notepad dan menampilkan deskripsi file dan nomor versi di jendela konsol.

#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

Berlaku untuk

Lihat juga