how can i check if a given Sharepoint path through a command line argument is 开发者_高级运维a root sharepoint path?
You can check SPWeb.IsRootWeb property.
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.
精彩评论