Пример #1
0
        /// <summary>
        /// Delete an app pool
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool DeleteAppPool(string name)
        {
            if (IISAppPool.Exsit(name) == false)
            {
                return(false);
            }

            IISAppPool appPool = IISAppPool.OpenAppPool(name);

            appPool._entry.DeleteTree();
            return(true);
        }
Пример #2
0
        /// <summary>
        /// create app pool
        /// </summary>
        /// <param name="name">the app pool to be created</param>
        /// <returns>IISAppPool created if success, else null</returns>
        public static IISAppPool CreateAppPool(string name)
        {
            DirectoryEntry Service = new DirectoryEntry("IIS://localhost/W3SVC/AppPools");

            foreach (DirectoryEntry entry in Service.Children)
            {
                if (entry.Name.Trim().ToLower() == name.Trim().ToLower())
                {
                    return(IISAppPool.OpenAppPool(name.Trim()));
                }
            }

            // create new app pool
            DirectoryEntry appPool = Service.Children.Add(name, "IIsApplicationPool");

            appPool.CommitChanges();
            Service.CommitChanges();

            return(new IISAppPool(appPool));
        }