karlstackoverflow
karlstackoverflow

Reputation: 3418

c# check if a given Sharepoint path is a root sharepoint path?

how can i check if a given Sharepoint path through a command line argument is a root sharepoint path?

Upvotes: 2

Views: 2820

Answers (2)

Alexei Levenkov
Alexei Levenkov

Reputation: 100547

In case you are running command line tool on the server you can use server side SharePoint OM like Petr Abdulin suggested:

new SPSite(url).OpenWeb().IsRootWeb

If you are running code on some random machine (that is not part of the farm) you will have to use Web Services (http://msdn.microsoft.com/en-us/library/dd878586(v=office.12).aspx ) or client side OM for SharePoint 2010 - http://msdn.microsoft.com/en-us/library/ee857094.aspx. Also in this case you sort of have to guess what part of the path is root web - I'd slowly increase prefixes of the Url till I can get SharePoint Web object corresponding to that path.

Upvotes: 1

pabdulin
pabdulin

Reputation: 35225

You can check SPWeb.IsRootWeb property.

Upvotes: 4

Related Questions