KnownFolders Class

Definition

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.

public ref class KnownFolders abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class KnownFolders final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public static class KnownFolders
Public Class KnownFolders
Inheritance
Object Platform::Object IInspectable KnownFolders
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

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

StorageFolder storageFolder = KnownFolders.PicturesLibrary;
StorageFile file = await storageFolder.CreateFileAsync("sample.png", CreationCollisionOption.ReplaceExisting);
// Do something with the new file.

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

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 App capability declarations.

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

Version history

Windows version SDK version Value added
1511 10586 GetFolderForUserAsync
2004 19041 GetFolderAsync
2004 19041 RequestAccessAsync
2004 19041 RequestAccessForUserAsync

Properties

AppCaptures

Gets the App Captures folder.

CameraRoll

Gets the Camera Roll folder.

DocumentsLibrary

Gets the Documents library. The Documents library is not intended for general use.

HomeGroup

Gets the HomeGroup folder.

MediaServerDevices

Gets the folder of media server (Digital Living Network Alliance (DLNA)) devices.

MusicLibrary

Gets the Music library.

Objects3D

Gets the Objects 3D folder.

PicturesLibrary

Gets the Pictures library.

Playlists

Gets the play lists folder.

RecordedCalls

Gets the recorded calls folder.

RemovableDevices

Gets the removable devices folder.

SavedPictures

Gets the Saved Pictures folder.

VideosLibrary

Gets the Videos library.

Methods

GetFolderAsync(KnownFolderId)

Retrieves the folder for the folderId specified.

GetFolderForUserAsync(User, KnownFolderId)

Static method that returns a specified known folder for a User.

RequestAccessAsync(KnownFolderId)

Requests access for the capability controlling access to the folder.

RequestAccessForUserAsync(User, KnownFolderId)

Requests access for the user and folderId.

Applies to

See also