Programmatically access the sharepoint sites under wildcard inclusion RRS feed

  • Question

  • Hi,
    Is there a way I can access programmatically the Site Collections under a Wildcard Inclusion for a web application.
    I have a site http://servername/<WildcardInclusion>/<mySiteCollection>. How can I access this programmatically?

    Basically, I need to increase the size of these sites, mainly, the size of "mySites". The approach of getting mySites through UserProfiles doesn't work out well for me.

    Thanks in Advance for your replies,
    • Changed type Mike Walsh FIN Wednesday, July 8, 2009 2:15 PM always use the question type so people get credit for replies
    Wednesday, July 8, 2009 1:49 PM


  • Hi roys,

    so you want all sites whose URL fits a regex?

                System.Text.RegularExpressions.Regex oRegexChecker = new System.Text.RegularExpressions.Regex("searchexpression");
                System.Collections.ArrayList oAppropriateSites = new System.Collections.ArrayList();
                String url="";
                foreach (SPSite site in SPContext.Current.Web.Site.WebApplication.Sites)
                    url = url.Substring(0, url.LastIndexOf("/"));
                    if (oRegexChecker.Matches(url))
                foreach (Guid siteID in oAppropriateSites)
                    using (SPSite site = new SPSite(siteID))
                        //do what you want with the site

    That's assuming you have only 1 webapplication, if there are more iterate through each of them starting from a SPFarm-instance.

    Wednesday, July 8, 2009 3:28 PM