Windows Phone 8: Media File Access

Windows Phone 8: Media file access

KnownFolders doesn't work on WP8 for 3rd party apps.

In terms of access on WP8 here's what's available:

  • Contacts: Read access available since WP7.5, write-access available via WP8 ContactStore.
  • Appointments: Read-access available since WP7.5. In WP8 you can add individual appointments after user confirmation via the SaveAppointmentTask.
  • Photos: Read access to all folders available since WP7. Write-access to Camera Roll and Saved Pictures available since WP7.5.
  • Audio: Developers can iterate over the music library and even play it via the native player since WP7. Starting WP8 developers can add songs to the music library using MediaLibraryExtensions.SaveSong().
  • Video: Read-write isn't available. There are security and storage issue with transporting files that big.
  • uSD Card: Starting WP8 apps can register for specific file extensions and read those from the micro-SD card.
  • Documents: No read-write access. But starting WP8 developers can open up docx/xlsx/etc files using Launcher.LaunchFileAsync and it will open up a read-only copy in Office. Users can then choose to save that copy in the Office Hub.

I've made this post a wiki so if there are any additional areas, feel free to edit and add those bullet points.

Windows Phone 8.0 - Access phone's local storage

There is no API in WP8 to list all the files in storage. In WP8 you can only access Audio and image files.

For more details refer this.

Read from internal storage in Windows Phone 8?

I am not sure where specifically you mean by internal storage, but there are a few locations you can access on the device.

Application Data (Formerly Isolated Storage)

This is the bread and butter location for an app to access. It is your own private location to store settings or files that you may have.

It can be accessed with:

StorageFolder localRoot = ApplicationData.Current.LocalFolder:

There is more documentation here with examples as well.

Libraries

These are common locations where apps are able to store and access media data. Accessing these requires declaring the capability for the area you are accessing and the file associations for the files you would like to see.

For example getting the camera roll folder would require the following:

In WMAppManifest:

<Capability Name="ID_CAP_MEDIALIB_PHOTO" /> 

The C#

StorageFolder cameraRoll = KnownFolders.CameraRoll;

There is more documentation of the different capabilities in the designer in Visual Studio. (The summaries there are easier to get a brief understanding with than the full MSDN articles.)

KnownFolders has access to all of the different locations that you can get at internally using it. Careful though, some of the locations are Windows or Phone specific, but they are all documented so you know which.

So there is no way to access videos on Windows Phone 8?

Unfortunately, there is no way to access videos in Media Library.

You have read-write access only to audio and photos.
See this answer: https://stackoverflow.com/a/13473349/1029518

Windows phone 8 get files in folder Music or Documents

Those two folders are available to a developer, as described in the answer on Windows Phone 8: Media file access

Songs and pictures

The api for songs and pictures seems to be
MediaLibrary according to the "Data for Windows Phone" page on MSDN.

It allows to add (SaveSong, SavePicture) and Delete songs and pictures from the library.

To be able to do this, you need the Capability ID_CAP_MEDIALIB_AUDIO and ID_CAP_MEDIALIB_PHOTO set in the app's manifest.

Documents (Windows RT only, not phone)

The documents folder can be accessed through the StorageFolder Api as described in the File access sample

StorageFolder storageFolder = KnownFolders.DocumentsLibrary; 

Downloading files

To download files from a computer is an entire different question and requires some more information from your end:

  • how do you want to download files from the computer
  • does the computer have a file sharing server
  • what protocol do you want to use
  • ...

If you are going to write a program for that computer to share files to your phone, then these Windows Phone 8 Networking Samples can provide some information on how to get sockets, nfc, bluetooth or http going on windows phone 8.



Related Topics



Leave a reply



Submit