Skip to content

Latest commit

 

History

History
65 lines (41 loc) · 3.44 KB

knownfolders.md

File metadata and controls

65 lines (41 loc) · 3.44 KB
-api-id -api-type
T:Windows.Storage.KnownFolders
winrt class

Windows.Storage.KnownFolders

-description

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.

-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

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

-see-also

File access sample, File access permissions, Enumerate and query files and folders, StorageFile class, StorageFolder class, Windows.Storage.Search namespace, HomeGroup sample (Windows 10)