Tonight I started working on a random project for Windows Phone 8.1. I didn't plan to create a Windows 8 application, but figured I'd give the new Universal App a try to leave my options open.

Anyways let's get to it... The app needs access to the users camera roll to perform some basic operations and return some basic metadata to the user. In the past you'd use the MediaLibrary object in Windows Phone 7 . However, when writing a Universal Application using Portable Class Libraries this option is no longer available.

I would argue that this is much easier to do now than it was previously, it just took a little time to figure out how.

First, don't forget to declare the capability in the Package.appxmanifest located in the Windows and Windows Phone projects alike.

Once you've done this you can now use the Windows.Storage.KnownFolders class to access the Pictures Library.

Here is how to get to the camera roll:

One thing to look out for is if the folder doesn't exist on the user's phone yet, this will throw a System.IO.FileNotFoundException which you need to handle however you see fit.

Simple as that! From there you can do whatever you'd like with the enumerable of StorageFiles. This code works in both the Windows Phone 8.1 XAML App and the Windows 8 App. Keep in mind that you can do many other things with the Windows.Storage.KnownFolders file structure, this is just one quick example.