1

I am bit stuck with the problem, i have created a document library in sharepoint directory path containing images.

I am trying to get all the images from this folder with their name and URL.

But couldn't find any solution using CSOM.

If anyone can help?

1 Answer 1

1

The code is quite simple, check this example

using (ClientContext ctx = new ClientContext("Your site name"))
        {
            Web web = ctx.Web;
            ctx.Load(web);
            Microsoft.SharePoint.Client.List docList = web.Lists.GetByTitle("Document library Name");
            ctx.Load(docList);
            CamlQuery camlQuery = new CamlQuery();
            //This will get all items in folders
            camlQuery.ViewXml = "<View Scope='RecursiveAll'></View>";
            ListItemCollection listCol = docList.GetItems(camlQuery);
            ctx.Load(listCol);
            ctx.ExecuteQuery();

            foreach (Microsoft.SharePoint.Client.ListItem item in listCol)
            {
                //item["FileDirRef"] //Title
                //item["FileLeafRef"] //url
            }
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.