KnownFolders
KnownFolders
KnownFolders
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 : static class KnownFolderspublic static class KnownFoldersPublic Static Class KnownFolders// You can use this class in JavaScript.
- Attributes
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
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 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.
- 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.
More info
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.
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// You can use this property in JavaScript.
The App Captures folder.
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// You can use this property in JavaScript.
The Camera Roll folder.
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
picturesLibrary
|
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// You can use this property in JavaScript.
The Documents library.
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
documentsLibrary
|
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 LocalCache 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// You can use this property in JavaScript.
The HomeGroup folder.
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.
- See Also
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// You can use this property in JavaScript.
The folder of media server (Digital Living Network Alliance (DLNA)) devices.
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// You can use this property in JavaScript.
The Music library.
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
musicLibrary
|
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
- See Also
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// You can use this property in JavaScript.
The Objects 3D folder.
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// You can use this property in JavaScript.
The Pictures library.
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
picturesLibrary
|
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
- See Also
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// You can use this property in JavaScript.
The play lists folder.
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
musicLibrary
|
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// You can use this property in JavaScript.
The recorded calls folder.
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
recordedCallsFolder
|
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// You can use this property in JavaScript.
The removable devices folder.
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
removableStorage
|
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// You can use this property in JavaScript.
The Saved Pictures folder.
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// You can use this property in JavaScript.
The Videos library.
| Device family |
Windows 10 (introduced v10.0.10240.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v1)
|
| Capabilities |
videosLibrary
|
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
- See Also
Methods
GetFolderForUserAsync(User, KnownFolderId) GetFolderForUserAsync(User, KnownFolderId) GetFolderForUserAsync(User, KnownFolderId) GetFolderForUserAsync(User, KnownFolderId)
Static method that returns a specified known folder for a User.
public : static IAsyncOperation<StorageFolder> GetFolderForUserAsync(User user, KnownFolderId folderId)public static IAsyncOperation<StorageFolder> GetFolderForUserAsync(User user, KnownFolderId folderId)Public Static Function GetFolderForUserAsync(user As User, folderId As KnownFolderId) As IAsyncOperation( Of StorageFolder )// You can use this method in JavaScript.
The ID of the folder to be returned.
When this method completes, it returns the requested StorageFolder object.
| Device family |
Windows 10 (introduced v10.0.10586.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v2)
|
- See Also