you can get the IIS Version programically by using following way. If you are using Windows 2003 or Windows Vista then you can get by using
DirectoryEntry dirRoot = new DirectoryEntry(IISRoot);
DirectoryEntry child = dirRoot.Children.Find("Info", "IIsWebInfo");
foreach (PropertyValueCollection c in child.Properties)
{
if (string.Compare(c.PropertyName, "MajorIIsVersionNumber", StringComparison.CurrentCultureIgnoreCase) == 0)
{
return Convert.ToInt16(c.Value, CultureInfo.InvariantCulture);
}
}
But if you are using windows XP then It is difficult to get it as it store in a binary. So I tried following way to get the IIS Version and in my case it works fine.
try
{
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + @"\inetsrv\inetinfo.exe");
Console.WriteLine("Version:" + fvi.FileVersion +"\nMajor Part: " + fvi.FileMajorPart + "." + fvi.FileMinorPart);
}
catch (FileNotFoundException ex)
{
throw ex;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment