BasicProperties 클래스

정의

항목의 크기 또는 항목이 마지막으로 수정된 날짜와 같은 기본 속성(예: 파일 또는 폴더)에 대한 액세스를 제공합니다.

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

Windows 요구 사항

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

예제

파일 액세스 샘플에서는 SizeDateModified와 같은 기본 속성을 포함하여 파일의 속성을 검색하는 방법을 보여 줍니다.

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

        // Get basic properties
        BasicProperties basicProperties = await file.GetBasicPropertiesAsync();
        outputText.AppendLine("File size: " + basicProperties.Size + " bytes");
        outputText.AppendLine("Date modified: " + basicProperties.DateModified);

        // 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
}

GetBasicPropertiesAsyncbasicProperties 완료되면 BasicProperties 개체를 가져옵니다.

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

설명

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

다음 메서드 및 속성을 사용하여 BasicProperties 개체를 가져올 수 있습니다.

속성

DateModified

파일이 마지막으로 수정된 시간의 타임스탬프를 가져옵니다.

ItemDate

항목에 가장 관련성이 큰 날짜를 가져옵니다.

Size

파일의 크기를 바이트 단위로 가져옵니다.

메서드

RetrievePropertiesAsync(IIterable<String>)

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

SavePropertiesAsync()

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

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

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

적용 대상

추가 정보