I want to get the Image URL from picture library and from the folders inside the library in SharePoint. I have tried both internal names ows_FileRef and ows_EncodedAbsUrl.
For ows_FileRef it is showing id and # in front of the image url.
For ows_EncodedAbsUrl it is showing as undefined.
Please help me to figure it out.
You can use the following code to iterate through folders as per your requirement:
SPFolder folder = ListPicture.RootFolder.SubFolders["picLib"];
And then you can use SpQuery to get the data:
string SPtestQuery = "<Where><Eq><FieldRef Name='ContentTypeId'/><Value Type='ContentTypeId'>"
+ GlobalConfiguration.Current.Items[Constants.ConfigurationKeys.ContentTypeID]
+ "</Value></Eq></Where><OrderBy><FieldRef Name='Date' Ascending='FALSE' /></OrderBy>";
string SPTestFields = string.Concat(
"<FieldRef Name='FileLeafRef'/>",
"<FieldRef Name='FileDirRef'/>",
"<FieldRef Name='ID'/>",
"<FieldRef Name='GalleryImage'/>",
"<FieldRef Name='Title'/>");
string listUrl = SPUrlUtility.CombineUrl(web.Url, "picLib");
You can get the data in datatable.