DocumentProperties 클래스

정의

항목의 문서 관련 속성(예: 파일 또는 폴더)에 대한 액세스를 제공합니다.

public ref class DocumentProperties sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class DocumentProperties final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class DocumentProperties
Public NotInheritable Class DocumentProperties
상속
Object Platform::Object IInspectable DocumentProperties
특성
구현

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

이 예제에서는 시스템 인덱스에서 백업하는 파일 쿼리를 사용하여 Title과 같은 문서 속성을 검색하는 방법을 보여 줍니다.

try
{
    // Create index backed file query and get results
    List<string> fileTypeFilter = new List<string>();
    fileTypeFilter.Add(".docx");
    QueryOptions queryOptions = new QueryOptions(Windows.Storage.Search.CommonFileQuery.OrderByName, fileTypeFilter);
    queryOptions.IndexerOption = IndexerOption.OnlyUseIndexer;
    StorageFileQueryResult queryResult = Windows.Storage.KnownFolders.DocumentsLibrary.CreateFileQueryWithOptions(queryOptions);
    var files = await queryResult.GetFilesAsync();

    // Process resulting files
    if (files.Count == 0)
    {
        // Perform tasks to handle no files found
    }
    else
    {
        // Access properties for each file
        foreach (StorageFile file in files)
        {
            var documentProperties = await file.Properties.GetDocumentPropertiesAsync();
            // Perform tasks with document properties
            String title = documentProperties.Title;
        }
    }
}
// Handle errors with catch blocks
catch (FileNotFoundException)
{
 // For example, handle a file not found error
}

이 예제에서는 DocumentsLibrary 를 사용하여 쿼리를 만드는 동안 StorageFolder로 가져올 수 있는 액세스 권한이 있는 폴더에 대해 다음과 같은 쿼리를 만들 수 있습니다.

이 예제 file 에서는 속성을 검색할 파일을 나타내는 StorageFile 을 포함합니다.

설명

항목의 Properties 속성(예: 폴더 파일)에서 GetDocumentPropertiesAsync 메서드를 사용하여 DocumentProperties 개체에 비동기적으로 액세스하거나 사용할 수 있는 경우 DocumentProperties 속성을 동기적으로 사용할 수 있습니다. 다음 메서드 및 속성을 사용하여 DocumentProperties 개체를 가져올 수 있습니다.

참고

다른 앱(예: Microsoft Word)에서 정의한 속성 처리기를 사용하여 가져오기 또는 설정된 속성에 액세스할 수 없습니다. 대신 시스템 인덱스에서 백업하는 파일 쿼리를 사용하여 이러한 속성을 가져올 수 있습니다. 자세한 내용은 QueryOptions를 참조하세요.

속성에 액세스하는 방법에 대한 자세한 코드 샘플은 파일 액세스 샘플을 참조하세요.

속성

Author

문서 작성자의 컬렉션을 가져옵니다.

Comment

문서와 연결된 주석을 가져오거나 설정합니다.

Keywords

문서와 연결된 키워드의 컬렉션을 가져옵니다.

Title

문서의 제목을 가져오거나 설정합니다.

메서드

RetrievePropertiesAsync(IIterable<String>)

항목과 연결된 지정된 속성을 검색합니다.

SavePropertiesAsync()

항목과 연결된 모든 속성을 저장합니다.

SavePropertiesAsync(IIterable<KeyValuePair<String,Object>>)

항목과 연결된 지정된 속성 및 값을 저장합니다.

적용 대상

추가 정보