If you have a sp url , how do you know what is sites,subsites and directories?
…short answer seems to be : you don’t
Longer answer:
Split the url up in parts, try the url piece by piece until you know what is what…
private void ResolveUrlStringToServiceReferenceAndListNameAndDocName(string s, out string serviceadress, out string listname, out string docname) { serviceadress = ""; listname = ""; docname = ""; string[] ss = s.Split('/'); if (ss.Length < 4) return; string sitesandsubsites = ""; string list = ""; string server = ss[0] + "//" + ss[2]; for (int i = 3; i < ss.Length - 1; i++) { string sitepart = ss[i]; list = ss[i + 1].Replace("%20", " "); sitesandsubsites += "/" + sitepart; SharepointListReference.ListsSoapClient listProxy = new SharepointListReference.ListsSoapClient(); listProxy.Endpoint.Address = new System.ServiceModel.EndpointAddress(server + sitesandsubsites + "/_vti_bin/lists.asmx"); try { listProxy.GetList(list); serviceadress = listProxy.Endpoint.Address.Uri.AbsoluteUri; listname = list; listProxy.Close(); docname = ss[ss.Length - 1].Replace("%20", " "); return; } catch { // continue } } }
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home