hi ,
i want to get application pool names using C# and asp.net.
follwing is the code i am using to get name..
private void GetAppPoolNames()
{
System.DirectoryServices.DirectoryEntry Root = this.GetDirectoryEntry("IIS://localhost/W3SVC/AppPools");
//DirectoryEntry Root = new DirectoryEntry("IIS://localhost/W3SVC/1/Root");
if (Root == null)
{
Response.Write("No Child in AppPool");
}
else
{
foreach (DirectoryEntry dir in Root.Children)
{
System.DirectoryServices.PropertyCollection pr = dir.Properties;
//ApplicationPool pool = new ApplicationPool();
//pool.Name = dir.Name;
//DropDownList1.Items.Add(pool.Name);
DropDownList1.Items.Add(dir.Name);
}
}
}
private DirectoryEntry GetDirectoryEntry(string path)
{
DirectoryEntry root = null;
try
{
root = new DirectoryEntry(path);
}
catch
{
Response.Write("Could not access Node");
return null;
}
if (root == null)
{
Response.Write("Could not access Node");
return null;
}
return root;
}
But i am getting Error. COM error.
Help plz.