Monday, December 14, 2009

Delete all site groups programmatically.

SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite spSite = new SPSite("http://testserver/spsite"))
{
using (SPWeb spWeb = spSite.OpenWeb())
{
SPGroupCollection objCol = spWeb.SiteGroups;

for (int count = 0; count <= objCol.Count - 1; count++)
{
spWeb.SiteGroups.Remove(0);
}
}
}
});

No comments:

Post a Comment