アプリケーションのバージョン情報を取得する方法を2つ紹介します。 アプリケーションの更新通知などの仕組みに利用できると思います。using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO; using System.Reflection; // これを追加します Assembly using System.Diagnostics; // これを追加します FileVersionInfo namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { // 現在実行中のアセンブリ参照を取得してバージョンを取得する方法 Assembly asmbl = Assembly.GetExecutingAssembly(); AssemblyName name = asmbl.GetName(); MessageBox.Show(name.Version.ToString()); // ファイル名を指定して、そのファイルのバージョンを取得する方法 string filename = @"C:\src\FileMany\FileMany\bin\Release\FileMany.exe"; if (File.Exists(filename)) { FileVersionInfo filever = FileVersionInfo.GetVersionInfo(filename); MessageBox.Show(filever.FileVersion); } } } }
日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)
コメントを残す