SharePoint : how to get the list static name via web service method
When I create a list in sharepoint using a feature I specify the staticName which becomes part of the URL to the list.
When I query the li开发者_运维问答st, and want to get the name - now all the sharepoint web service sends back is the ID, for example: Name=\"{1836D8BB-77D3-4266-AA09-1ABB68E5C672}\"
How can I get the static name again?
Thanks
The GetList
method in the Lists.asmx web-service will return a field called DefaultViewUrl. It'll look like this :
DefaultViewUrl="/Site_Name/Lists/List_Name/AllItems.aspx"
The following code would then give you the static name :
String pattern = ".*/(?<listStaticName>.+)/[^\\.]+\\.aspx";
Regex regex = new Regex(pattern);
MatchCollection matches = regex.Matches(DefaultViewUrl);
String listStaticName = matches[0].Groups["listStaticName"].ToString();
Far from an elegant solution, but it will work.
EDIT : Actually, the SPList.RootFolder.Name should give you the same result for a document library.
精彩评论