KnownFolders 類別

定義

提供包含使用者內容之常見位置的存取權。 這包括使用者本機媒體櫃的內容, (例如檔、圖片、音樂和影片) 、HomeGroup、卸載式裝置和媒體伺服器裝置。

public ref class KnownFolders abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class KnownFolders final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public static class KnownFolders
Public Class KnownFolders
繼承
Object Platform::Object IInspectable KnownFolders
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

檔案 存取範例 示範如何使用 PicturesLibrary 屬性在圖片媒體櫃中建立新檔案。

StorageFolder storageFolder = KnownFolders.PicturesLibrary;
StorageFile file = await storageFolder.CreateFileAsync("sample.png", CreationCollisionOption.ReplaceExisting);
// Do something with the new file.

CreateFileAsync方法完成之後, file 變數會包含代表新檔案的StorageFile

備註

這個類別是靜態的,無法具現化。 直接存取其屬性,如下列範例所示。

  • StorageFolder storageFolder = KnownFolders.PicturesLibrary;

必要條件

若要存取此類別屬性所代表的資料夾和程式庫,請在應用程式資訊清單中指定對應的功能。 例如,若要存取 KnownFolders.PicturesLibrary,請在應用程式資訊清單中指定 圖片庫 功能。 深入瞭解 應用程式功能宣告中的功能。

傳回值

KnownFolders 類別的屬性會傳回 StorageFolder。 若要使用已知資料夾及其內容,請呼叫 StorageFolder 類別的方法和屬性。

其他資訊

以下是存取一些其他常用位置的方式。

若要深入瞭解您的應用程式可以存取的位置,請參閱 檔案存取權限

版本歷程記錄

Windows 版本 SDK 版本 新增值
1511 10586 GetFolderForUserAsync
2004 19041 GetFolderAsync
2004 19041 RequestAccessAsync
2004 19041 RequestAccessForUserAsync

屬性

AppCaptures

取得應用程式擷取資料夾。

CameraRoll

取得相機 Roll 資料夾。

DocumentsLibrary

取得文件庫。 文件庫不適用於一般用途。

HomeGroup

取得 HomeGroup 資料夾。

MediaServerDevices

取得媒體伺服器 (Digital Living Network Alliance (DLNA) ) 裝置的資料夾。

MusicLibrary

取得音樂媒體櫃。

Objects3D

取得 Objects 3D 資料夾。

PicturesLibrary

取得圖片媒體櫃。

Playlists

取得播放清單資料夾。

RecordedCalls

取得錄製的呼叫資料夾。

RemovableDevices

取得卸載式裝置資料夾。

SavedPictures

取得 [已儲存的圖片] 資料夾。

VideosLibrary

取得影片庫。

方法

GetFolderAsync(KnownFolderId)

擷取所指定 folderId 的資料夾。

GetFolderForUserAsync(User, KnownFolderId)

靜態方法,會傳回 User的指定已知資料夾。

RequestAccessAsync(KnownFolderId)

要求存取權,以控制資料夾的存取權。

RequestAccessForUserAsync(User, KnownFolderId)

要求使用者和 folderId 的存取權。

適用於

另請參閱