StorageItemContentProperties 클래스

정의

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

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

Windows 요구 사항

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

예제

이 예제에서는 StorageFile.Properties를 사용하여 파일에서 콘텐츠 속성 또는 지정된 속성을 검색하는 방법을 보여 줍니다.

try
{
    StorageFile file = rootPage.sampleFile;
    if (file != null)
    {
        StringBuilder outputText = new StringBuilder();

        // Get image properties
        ImageProperties imageProperties = await file.Properties.GetImagePropertiesAsync();
        outputText.AppendLine("Date taken: " + imageProperties.DateTaken);
        outputText.AppendLine("Rating: " + imageProperties.Rating);

        // Specify more properties to retrieve
        readonly string dateAccessedProperty = "System.DateAccessed";
        readonly string fileOwnerProperty = "System.FileOwner";
        List<string> propertiesName = new List<string>();
        propertiesName.Add(dateAccessedProperty);
        propertiesName.Add(fileOwnerProperty);

        // Get the specified properties through StorageFile.Properties
        IDictionary<string, object> extraProperties = await file.Properties.RetrievePropertiesAsync(propertiesName);
        var propValue = extraProperties[dateAccessedProperty];
        if (propValue != null)
        {
            outputText.AppendLine("Date accessed: " + propValue);
        }
        propValue = extraProperties[fileOwnerProperty];
        if (propValue != null)
        {
            outputText.AppendLine("File owner: " + propValue);
        }
    }
}
// Handle errors with catch blocks
catch (FileNotFoundException)
{
 // For example, handle a file not found error
}

GetImagePropertiesAsync가 완료되면 imagePropertiesImageProperties 개체를 가져옵니다. 또한 RetrievePropertiesAsync 가 완료되면 extraProperties 는 지정된 속성이 포함된 개체를 가져옵니다(지원되는 속성 목록은 Core 속성 페이지에서 찾을 수 있음).

예제에서 파일에 는 속성을 검색할 파일을 나타내는 StorageFile 이 포함되어 있습니다.

설명

다음 개체에서 사용할 수 있는 Properties 속성을 사용하여 StorageItemContentProperties 개체를 가져올 수 있습니다.

참고

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

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

메서드

GetDocumentPropertiesAsync()

항목의 문서 속성(예: 폴더 파일)을 검색합니다.

GetImagePropertiesAsync()

항목의 이미지 속성(예: 폴더 파일)을 검색합니다.

GetMusicPropertiesAsync()

항목의 음악 속성(예: 폴더 파일)을 검색합니다.

GetVideoPropertiesAsync()

항목의 비디오 속성(예: 폴더 파일)을 검색합니다.

RetrievePropertiesAsync(IIterable<String>)

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

SavePropertiesAsync()

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

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

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

적용 대상

추가 정보