檢查虛擬目錄是否存在。
VerifyVirtualPathIsExist public static bool VerifyVirtualPathIsExist(string siteName, string path)
{
using (ServerManager mgr = new ServerManager())
{
Site site = mgr.Sites[siteName];
if (site != null)
{
foreach (Microsoft.Web.Administration.Application app in site.Applications)
{
if (app.Path.ToUpper().Equals(path.ToUpper()))
{
return true;
}
}
}
}
return false;
}
檢查站點是否存在。
VerifyWebSiteIsExist public static bool VerifyWebSiteIsExist(string siteName)
{
using (ServerManager mgr = new ServerManager())
{
for (int i = 0; i < mgr.Sites.Count; i++)
{
if (mgr.Sites[i].Name.ToUpper().Equals(siteName.ToUpper()))
{
return true;
}
}
}
return false;
}