GetImagePropertiesAsync() returns an ImageProperties.DateCreated of: {12/31/1600 7:00:00 PM -05:00}

Allanjb 246 Reputation points
2020-08-15T17:01:15.147+00:00

Property: StorageFile.DateCreated has a value of "12/31/1600 7:00:00 PM -05:00", (Eastern Standard Time) when returned form a call to: StorageFile.Properties.GetImagePropertiesAsync(). In Windows Explorer the DateTime is blank.

for example, (in C#):

 StorageFile imageFile = await StorageFile.GetFileFromPathAsync(folderPath);
 ImageProperties props = await imageFile.Properties.GetImagePropertiesAsync();

props.DateTaken = "12/31/1600 7:00:00 PM -05:00"

The documentation for StorageFile.DateCreated states:

"If the date property isn't set, this value defaults to 0 which can be translated into misleading dates in different programming languages. In JavaScript, for example, 0 translates to December 16, 1600. You should always check that this property is a real value and not 0."

How do I check that the DateTaken is a real value? How do I check that the DateCreated has a value?

Developer technologies Universal Windows Platform (UWP)
{count} votes

Accepted answer
  1. Richard Zhang-MSFT 6,936 Reputation points Microsoft Employee Moderator
    2020-08-17T05:31:33.143+00:00

    Hello,

    Welcome to Microsoft Q&A.

    As the documentation says, without setting Date, you may get a misleading date.

    Nevertheless, we can make a simple judgment on the obtained Date:

    We can use DateTime.FromFileTime(0) to construct an identical value, and then compare it with the obtained DateTaken. If they are the same, the file does not have a date value set.

    if (props.DateTaken.Date==DateTime.FromFileTime(0))
    {
        //Invalid date.
    }
    else
    {
        //Do something
    }
    

    Thanks.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.