Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,845 questions

51,766 answers

573 users

How to get windows file version information using WinForms in C#

1 Answer

0 votes
using System.Diagnostics;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public void GetFileVersion(string filename)
        {
            FileVersionInfo.GetVersionInfo(Path.Combine(Environment.SystemDirectory, filename));
            FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + "\\" + filename);

            textBox1.Text = "File: " + myFileVersionInfo.FileDescription + '\n' +
                            "Version number: " + myFileVersionInfo.FileVersion;
        }
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            GetFileVersion("Notepad.exe");
            GetFileVersion("Calc.exe");
            GetFileVersion("msvcrt.dll");
        }
    }
}



/*
run:

File: Notepad
Version number: 10.0.19041.4165 (WinBuild.160101.0800)
File: Windows Calculator
Version number: 10.0.19041.1 (WinBuild.160101.0800)
File: Windows NT CRT DLL
Version number: 7.0.19041.3636 (WinBuild.160101.0800)

*/

 



answered Jul 16, 2024 by avibootz
...