-api-id | -api-type |
---|---|
T:Windows.Storage.KnownFolders |
winrt 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.
This class is static and cannot be instantiated. Access its properties directly, as shown in the following example.
StorageFolder storageFolder = KnownFolders.PicturesLibrary;
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.
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.
- For info about how to use pictures, music, and videos in your app, see Audio, video, and camera.
- For general info about how to use files and folders, see Enumerate and query files and folders.
Here's how to access some other commonly used locations.
- Get the app's local folder from the Windows.Storage.ApplicationData.Current.LocalFolder property.
- Get the app's installation folder from the Windows.ApplicationModel.Package.Current.InstalledLocation property.
To learn more about the locations that your app can access, see File access permissions.
Windows version | SDK version | Value added |
---|---|---|
1511 | 10586 | GetFolderForUserAsync |
2004 | 19041 | GetFolderAsync |
2004 | 19041 | RequestAccessAsync |
2004 | 19041 | RequestAccessForUserAsync |
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.
File access sample, File access permissions, Enumerate and query files and folders, StorageFile class, StorageFolder class, Windows.Storage.Search namespace, HomeGroup sample (Windows 10)