I have a photo gallery library. I want to get all albums and their images. Now I get all albums (root level items) with something like this:

ClientContext ctx = new ClientContext(_url);
_mylib = web.Lists.GetByTitle("mylib");
_albums = _list.GetItems(new CamlQuery());

_albums represents albums, on the root of the gallery. How do I get files/items in each of these albums?


I did something very similar to this recently (Picture Libraries, Client object model, silverlight).

What I did different was each "album" was in it's own Picture Library.

When I give the user the option to select an album, I gather a ListCollection of lists where the BaseType is that of a Picture Library (can't remember the exact number now, search around for it though) - and put this list into a DropdownList.

Stick an event handler onto the DropdownList such that when it's changed, the selected item is pulled out, put into a CAML Query which loads all items from a specified list (by GUID).

In short? Avoid folders, use separate lists/libraries instead. If you must keep them in the same library, then add a column to store an "Album Name". Then do a CAML Query to filter based on a value in this column, this will return all files in a specific "album".

  • I managed to get all albums + images using Folder and Folder.Files in them. The only problem now is that I must test it at work. I will accept you answer if no better comes, because it's one of the solutions to the problem. – redman Feb 7 '11 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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