KnownFolders class

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


public static class KnownFolders

Members

The KnownFolders class has these types of members:

Methods

The KnownFolders class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

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

 

Properties

The KnownFolders class has these properties.

PropertyAccess typeDescription

AppCaptures

Read-only

Gets the App Captures folder.

CameraRoll

Read-only

Gets the Camera Roll folder.

DocumentsLibrary

Read-only

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

HomeGroup

Read-only

Gets the HomeGroup folder.

MediaServerDevices

Read-only

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

MusicLibrary

Read-only

Gets the Music library.

Objects3D

Read-only

Gets the Objects 3D folder.

PicturesLibrary

Read-only

Gets the Pictures library.

Playlists

Read-only

Gets the play lists folder.

RecordedCalls

Read-only

Gets the recorded calls folder.

RemovableDevices

Read-only

Gets the removable devices folder.

SavedPictures

Read-only

Gets the Saved Pictures folder.

VideosLibrary

Read-only

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

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.

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

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

Attributes

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

See also

Object
File access sample
Access to user resources using the Windows Runtime
File access permissions
Enumerate and query files and folders
Reference
StorageFile class
StorageFolder class
Windows.Storage.Search namespace
HomeGroup sample (Windows 10)

 

 

Show:
© 2016 Microsoft