locked
How it may happen that file CreationTime appears to be LESS then LastWriteTime? RRS feed

  • Question

  • This small fragment

    Get-Item .\*.ps1 |
    %{
        $t1 = $_.CreationTime.ToString( "yyyy-MM-dd HH:mm:ss" );
        $t2 = $_.LastWriteTime.ToString( "yyyy-MM-dd HH:mm:ss" );
        $t4 = $_.Name;
        if( $t1 -lt $t2 )
        {
            "$t1 $t2     $t4"
        }
        else
        {
            "$t2 $t1 *** $t4"
        }
    }

    Outputs:

    2018-08-28 08:57:55 2018-08-28 09:02:35 *** DirSize.ps1
    2018-08-19 10:34:37 2018-08-19 11:40:36     FindDownload.ps1
    2018-08-18 12:05:42 2018-08-19 10:11:20 *** FindEmail.ps1
    2018-05-07 16:39:52 2018-08-18 21:29:40 *** GBHUtils.ps1
    2018-07-24 12:24:26 2018-08-23 15:39:24 *** Get-Last-Best.ps1
    2018-08-19 15:40:28 2018-08-23 15:45:51     Get-StampValues.ps1
    2018-08-06 20:26:11 2018-08-18 21:29:40 *** GetBuildsHistory.ps1
    2018-08-19 16:47:16 2018-08-28 09:11:17     LogsDigger.ps1
    2018-05-11 22:44:11 2018-08-23 15:39:30 *** MergeReportingEvents.ps1
    2018-08-26 17:16:55 2018-08-27 23:10:57     Test-Get-BuildsDirs.ps1
    2018-08-18 21:29:40 2018-08-23 14:57:22     Test-LogsDigger.ps1
    2018-08-15 19:07:23 2018-08-18 21:29:40 *** Utils.ps1
    2018-08-23 14:40:47 2018-08-23 14:44:38 *** Verify-LogsDigger-Reports.ps1
    2018-08-22 15:04:41 2018-08-22 20:23:22     WhoAmI.ps1

    I open https://docs.microsoft.com/en-us/dotnet/api/system.io.filesysteminfo.creationtime?view=netframework-4.7.2 and read: FileSystem.CreationTime property Gets or sets the creation time of the current file or directory. And LastWiteTime property Gets or sets the time when the current file or directory was last written to. 

    Thus I can not understand WHY sometimes CreationTime appears to be GREATER then LastWriteTime as my example shows and is it possible to belive CreationDate property value. LastWriteTime property seems being always correct.

    HAVE FOUND AN ANSWER in: https://stackoverflow.com/questions/10277741/how-can-fileinfo-lastwritetime-be-earlier-than-fileinfo-creationtime








    Tuesday, August 28, 2018 7:30 AM

Answers