KnownFolders class

Applies to Windows and Windows Phone

Provides access to common locations that contain user content. This includes content from a user's local libraries (such as Documents, Pictures, Music, and Videos), HomeGroup, removable devices, and media server devices.

Syntax


var knownFolders = Windows.Storage.KnownFolders;

Attributes

[MarshalingBehavior(Agile)]
[Version(0x06020000)]

Members

The KnownFolders class has these types of members:

Methods

The KnownFolders class inherits methods from the Object class (C#/VB/C++).

Properties

The KnownFolders class has these properties.

PropertyAccess typeDescription

CameraRoll

Read-onlyGets the Camera Roll folder.

DocumentsLibrary

Read-onlyGets the Documents library. The Documents library is not intended for general use.

HomeGroup

Read-onlyGets the HomeGroup folder.

MediaServerDevices

Read-onlyGets the folder of media server (Digital Living Network Alliance (DLNA)) devices.

MusicLibrary

Read-onlyGets the Music library.

PicturesLibrary

Read-onlyGets the Pictures library.

Playlists

Read-onlyGets the play lists folder.

RemovableDevices

Read-onlyGets the removable devices folder.

SavedPictures

Read-onlyGets the Saved Pictures folder.

VideosLibrary

Read-onlyGets the Videos library.

 

Remarks

This class is static and cannot be instantiated. Access its properties directly, as shown in the following example.

StorageFolder storageFolder = KnownFolders.PicturesLibrary;

Prerequisites

To access the folders and libraries represented by the properties of this class, specify the corresponding capabilities in your app manifest. For example, to access KnownFolders.PicturesLibrary, specify the Pictures Library capability in the app manifest. Learn more about capabilities in Access to user resources using the Windows Runtime.

Return value

The properties of the KnownFolders class return a StorageFolder. To work with the known folder and its contents, call the methods and properties of the StorageFolder class.

More info

Here's how to access some other commonly used locations.

To learn more about the locations that your app can access, see File access and permissions in Windows Store apps.

Examples

The File access sample shows you how to use the PicturesLibrary property to create a new file in the Pictures library.


Windows.Storage.KnownFolders.picturesLibrary.createFileAsync("sample.png", Windows.Storage.CreationCollisionOption.replaceExisting).done(
   function (file) {
       // Process file
   },
   // Handle errors with an error function
   function (error) {
       // Process errors
   }
);

After the CreateFileAsync method completes, the file variable contains a StorageFile that represents the new file.

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8

Namespace

Windows.Storage
Windows::Storage [C++]

Metadata

Windows.winmd

See also

File access sample
Access to user resources using the Windows Runtime
File access and permissions in Windows Store apps
Quickstart: Accessing files programmatically
Reference
StorageFile class
StorageFolder class
Windows.Storage.Search namespace

 

 

Show:
© 2014 Microsoft