0

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?

mylib
-album1
--image1.jpg
--image2.jpg
-album2
--image1.jpg
...

1 Answer 1

1

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".

1
  • 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
    Commented Feb 7, 2011 at 17:15

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.