NinethSense oWnZ mE!: Praveen’s drawing book

Choose a Topic:

Tue
15
Jan '08

.NET Version Checker

Old theme but still users aksing me.

try
            {
                this.Hide();
                string[] dirs = Directory.GetDirectories(Environment.GetEnvironmentVariable(“WinDir”) + \Microsoft.NET\Framework”);
                Array.Sort(dirs);
 
                for (int i = 0; i < dirs.Length; i++)
                {
                    if (char.IsDigit(Path.GetFileName(dirs[i]), 1) && !char.IsDigit(Path.GetFileName(dirs[i]), 0))
                    {
                        lblVersion.Text += Path.GetFileName(dirs[i]) + \n;
 
                    }
                }
                this.Show();
            }
            catch
            {
                MessageBox.Show(“This applicaiton is not compatible with this Computer. Application Terminated.”);
                Application.Exit();
            }


Above code will list all available .NET versions in a machine.

Earlier I puslished another code based on user agent string which you can check at http://blog.ninethsense.com/general/aspnet-how-to-detect-net-version-from-browser-using-user-agent-string/
The CodeProject Microsoft Developer Network Official ASP.NET Forums Microsoft .NET Framework Community Microsoft Most Valuable Professional Kidoos forums Microsoft Visual Studio Developer Home Professional Information Technology Solutions Microsoft Research Home Trivandrum Microsoft Users Group Community Website