Tue
15
Jan '08
Old theme but still users aksing me.
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/
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/

Leave a passing comment »