KnownFolders KnownFolders KnownFolders KnownFolders Class

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

Declaration

public static class KnownFolderspublic static class KnownFoldersPublic Static Class KnownFolders

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.

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.
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(System.String,Windows.Storage.CreationCollisionOption) method completes, the file variable contains a StorageFile that represents the new file.

Properties summary

Gets the App Captures folder.

Gets the Camera Roll folder.

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

Gets the HomeGroup folder.

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

Gets the Music library.

Gets the Objects 3D folder.

Gets the Pictures library.

Gets the play lists folder.

Gets the recorded calls folder.

Gets the removable devices folder.

Gets the Saved Pictures folder.

Gets the Videos library.

Methods summary

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

Properties

  • AppCaptures
    AppCaptures
    AppCaptures
    AppCaptures

    Gets the App Captures folder.

    public static StorageFolder AppCaptures { get; }public static StorageFolder AppCaptures { get; }Public Static ReadOnly Property AppCaptures As StorageFolder

    Property Value

  • CameraRoll
    CameraRoll
    CameraRoll
    CameraRoll

    Gets the Camera Roll folder.

    public static StorageFolder CameraRoll { get; }public static StorageFolder CameraRoll { get; }Public Static ReadOnly Property CameraRoll As StorageFolder

    Property Value

    Remarks

    To access the Camera Roll folder, in the app manifest, specify the Pictures Library capability.

    Windows Store app only. If the Camera Roll folder doesn't exist, reading the value of this property creates it. It does not raise an exception. The Camera Roll folder is typically a subfolder in the Pictures library that has the following path.

    • %USERPROFILE%\Pictures\Camera Roll
  • DocumentsLibrary
    DocumentsLibrary
    DocumentsLibrary
    DocumentsLibrary

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

    public static StorageFolder DocumentsLibrary { get; }public static StorageFolder DocumentsLibrary { get; }Public Static ReadOnly Property DocumentsLibrary As StorageFolder

    Property Value

    Remarks

    Important

    The Documents library is not intended for general use. For more info, see App capability declarations.

    If your app has to create and update files that only your app uses, consider using the app's LocalCacheFolder folder. For more information on which folders you should use for your app's data, see ApplicationData class.

    Alternatively, let the user select the file location by using a file picker. For more info, see Open files and folders with a picker.

    Prerequisites

    To access the Documents library, do the following things.

    • In the app manifest, specify the Documents Library capability. This capability is not visible in Manifest Designer. To add the Documents Library capability, open the app manifest in code view and edit the XML directly.
    • In the app manifest, register at least one File Type Association declaration. This declaration explicitly indicates the file types (extensions) that your app wants to access in the Documents library. The app can only enumerate, create, or change files that have the file types declared in the app manifest. For more info, see Handle file activation.

    Return value

    To work with the Documents library and its contents, call the methods and properties of the StorageFolder class. For general info about how to use files and folders, see Enumerate and query files and folders.

  • HomeGroup
    HomeGroup
    HomeGroup
    HomeGroup

    Gets the HomeGroup folder.

    public static StorageFolder HomeGroup { get; }public static StorageFolder HomeGroup { get; }Public Static ReadOnly Property HomeGroup As StorageFolder

    Property Value

    Remarks

    Prerequisites

    Before you can access the HomeGroup folder, the user's computer must belong to an existing HomeGroup.

    To access the HomeGroup folder, in the app manifest, specify at least one of the following capabilities: Pictures Library, Music Library, or Videos Library.

    More info

    In the HomeGroup folder, the app sees only the libraries that correspond to the capabilities specified in the app's manifest. For example, an app that specifies only the Pictures Library capability sees only the Pictures libraries in the HomeGroup folder.

  • MediaServerDevices
    MediaServerDevices
    MediaServerDevices
    MediaServerDevices

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

    public static StorageFolder MediaServerDevices { get; }public static StorageFolder MediaServerDevices { get; }Public Static ReadOnly Property MediaServerDevices As StorageFolder

    Property Value

    Remarks

    Prerequisites

    To access the media server devices folder, in the app manifest, specify at least one of the following capabilities: Pictures Library, Music Library, or Videos Library.

    More info

    In the media server devices folder, the app sees only the content that corresponds to the capabilities specified in the app's manifest. For example, an app that specifies only the Music Library capability sees only music content in the media server devices folder.

    Some Digital Media Servers only support a single media restriction. These servers may incorrectly return 0 files for a query if you've specified two media library capabilities in the app manifest. If you've specified two media library capabilities - for example, Pictures Library and Videos Library - and a query returns 0 files, try changing the capabilities to specify either a single media library capability or all three media library capabilities. If you specify all 3 media library capabilities, no media restrictions are sent and this problem doesn't occur.

  • MusicLibrary
    MusicLibrary
    MusicLibrary
    MusicLibrary

    Gets the Music library.

    public static StorageFolder MusicLibrary { get; }public static StorageFolder MusicLibrary { get; }Public Static ReadOnly Property MusicLibrary As StorageFolder

    Property Value

    Remarks

    To access the Music library, in the app manifest, specify the Music Library capability. For info about accessing the Music, Pictures, or Videos library in a Universal Windows app, see Files and folders in the Music, Pictures, and Videos libraries.

    The Music Library typically has the following path.

    • %USERPROFILE%\Music
  • Objects3D
    Objects3D
    Objects3D
    Objects3D

    Gets the Objects 3D folder.

    public static StorageFolder Objects3D { get; }public static StorageFolder Objects3D { get; }Public Static ReadOnly Property Objects3D As StorageFolder

    Property Value

  • PicturesLibrary
    PicturesLibrary
    PicturesLibrary
    PicturesLibrary

    Gets the Pictures library.

    public static StorageFolder PicturesLibrary { get; }public static StorageFolder PicturesLibrary { get; }Public Static ReadOnly Property PicturesLibrary As StorageFolder

    Property Value

    Remarks

    To access the Pictures library, in the app manifest, specify the Pictures Library capability.

    The Pictures Library typically has the following path.

    • %USERPROFILE%\Pictures
  • Playlists
    Playlists
    Playlists
    Playlists

    Gets the play lists folder.

    public static StorageFolder Playlists { get; }public static StorageFolder Playlists { get; }Public Static ReadOnly Property Playlists As StorageFolder

    Property Value

    Remarks

    To access the play lists folder, in the app manifest, specify the Music Library capability.

    The play lists folder is typically a subfolder in the Music library that has the following path.

    • %USERPROFILE%\Music\Playlists
  • RecordedCalls
    RecordedCalls
    RecordedCalls
    RecordedCalls

    Gets the recorded calls folder.

    public static StorageFolder RecordedCalls { get; }public static StorageFolder RecordedCalls { get; }Public Static ReadOnly Property RecordedCalls As StorageFolder

    Property Value

  • RemovableDevices
    RemovableDevices
    RemovableDevices
    RemovableDevices

    Gets the removable devices folder.

    public static StorageFolder RemovableDevices { get; }public static StorageFolder RemovableDevices { get; }Public Static ReadOnly Property RemovableDevices As StorageFolder

    Property Value

    Remarks

    Prerequisites

    To access the removable devices folder, you must:

    • In the app manifest, specify the Removable Storage capability.
    • In the app manifest, register at least one File Type Association declaration. This declaration explicitly indicates the file types (extensions) that your app wants to access on the removable devices. The app can only enumerate, create, or change files that have the file types declared in the app manifest. For more info, see Handle file activation.

    Return value

    To work with the removable devices folder and its contents, call the methods and properties of the StorageFolder class. For general info about how to use files and folders, see Enumerate and query files and folders.

    The folder returned by the RemovableDevices property is a virtual folder. This virtual folder contains a subfolder for each removable device that's present. For example, if a single removable device is attached to the computer, the removable devices folder contains a single subfolder for which the name and path may be D:\.

    If no removable devices are available, reading the value of this property returns an empty folder. It does not raise an exception.

  • SavedPictures
    SavedPictures
    SavedPictures
    SavedPictures

    Gets the Saved Pictures folder.

    public static StorageFolder SavedPictures { get; }public static StorageFolder SavedPictures { get; }Public Static ReadOnly Property SavedPictures As StorageFolder

    Property Value

    Remarks

    To access the Saved Pictures folder, in the app manifest, specify the Pictures Library capability.

  • VideosLibrary
    VideosLibrary
    VideosLibrary
    VideosLibrary

    Gets the Videos library.

    public static StorageFolder VideosLibrary { get; }public static StorageFolder VideosLibrary { get; }Public Static ReadOnly Property VideosLibrary As StorageFolder

    Property Value

    Remarks

    To access the Videos library, in the app manifest, specify the Videos Library capability.

    The Videos Library typically has the following path.

    • %USERPROFILE%\Videos

Methods

  • GetFolderForUserAsync(Windows.System.User,Windows.Storage.KnownFolderId)
    GetFolderForUserAsync(Windows.System.User,Windows.Storage.KnownFolderId)
    GetFolderForUserAsync(Windows.System.User,Windows.Storage.KnownFolderId)
    GetFolderForUserAsync(Windows.System.User,Windows.Storage.KnownFolderId)

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

    public static IAsyncOperation<StorageFolder> GetFolderForUserAsync(Windows.System.User user,Windows.Storage.KnownFolderId folderId)public static IAsyncOperation<StorageFolder> GetFolderForUserAsync(Windows.System.User user,Windows.Storage.KnownFolderId folderId)Public Static Function GetFolderForUserAsync(user As Windows.System.User,folderId As Windows.Storage.KnownFolderId) As IAsyncOperation( Of StorageFolder )

    Parameters

    Returns

    • When this method completes, it returns the requested StorageFolder object.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.StaticAttribute

Details

Assembly

Windows.Storage.dll