Logo
  Wednesday, September 08, 2010
Sign-In  |  Sign-Up  |  Contact Us  |  Bookmark |  RSS Feed

Check to see if SharePoint site exists  
One way to check for the SharePoint site existance is to pass site name to a method that wil return true or false based on the end result. Otherwise, you may run into run time errors when trying to add a file to the SharePoint site that does not exist.

private static bool CheckSPSite(string siteName) 
{
            using (SPSite site = new SPSite(siteName)) 
            { 
                using (SPWeb web = site.OpenWeb()) 
                {                     
                    if (!web.Exists) 
                    { 
                        return false; 
                    } 
                    else
                    { 
                        return true; 
                    } 
                } 
            } 
        }

I would recommend creating util Library where you can store all your helper methods and re-use in other projects.


Print Check to see if SharePoint site exists Bookmark Check to see if SharePoint site exists

Related Blogs  
Microsoft Exams - Part II
We published next batch of Microsoft exam reviews which will help you in your preparations for these
Google error visiting this site may harm your computer!
I was browsing google.com and saw underneath each link a message "This site may harm your computer"
Visual Studio 2010 Features List
Newer version of the Microsoft's Visual Studio called Visual Studio 2010 brings a new list of featur
Branching and Merging with Visual Studio 2010
We got new studio and we got new visual capability to manage Branching and Merging. This is really b
Microsoft Enterprise Library 4.1
Microsoft release updated version of its Microsoft Enterprise Library 4.1 back in October 2008. This
TFS Branching Guidance
TFS Branching is a hot topic amongst development team. There are many was to branch your project and
More
MayJune 2009Jul
MoTuWeThFrSaSu
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345