{"record":{"id":"8378cfec37849757","repo":"dotnet/wpf","slug":"sr-timestampnotavailable","errorCode":null,"errorMessage":"SR.TimeStampNotAvailable","messagePattern":"SR\\.TimeStampNotAvailable","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"warning","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/StorageInfo.cs","lineNumber":1148,"sourceCode":"\n        return returnValue;\n    }\n\n    /// <summary>\n    /// Convert a System.Runtime.InteropServices.FILETIME struct to the CLR\n    /// DateTime class.  Strange that the straightforward conversion doesn't \n    /// already exist.  Perhaps I'm just not finding it.  DateTime has a \n    /// method to convert itself to FILETIME, but only supports creating a\n    /// DateTime from a 64-bit value representing FILETIME instead of the\n    /// FILETIME struct itself.\n    /// </summary>\n    private DateTime ConvertFILETIMEToDateTime( System.Runtime.InteropServices.ComTypes.FILETIME time )\n    {\n        // We should let the user know when the time is not valid, rather than \n        //  return a bogus date of Dec 31. 1600.\n        if( 0 == time.dwHighDateTime &&\n            0 == time.dwLowDateTime )\n            throw new NotSupportedException(\n                SR.TimeStampNotAvailable);\n        \n        // CLR \n\n\n\n\n\n\n\n\n\n        return DateTime.FromFileTime(\n            (((long)time.dwHighDateTime) << 32) +\n              (uint)time.dwLowDateTime ); // This second uint is very important!!\n    }\n\n    /// <summary>","sourceCodeStart":1130,"sourceCodeEnd":1166,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/StorageInfo.cs#L1130-L1166","documentation":"ConvertFILETIMEToDateTime throws NotSupportedException with SR.TimeStampNotAvailable when both FILETIME parts are zero, meaning the compound file carries no valid timestamp. The library refuses to return a bogus date like Dec 31, 1600 that a zero FILETIME would convert to.","triggerScenarios":"Accessing CreationTime/LastWriteTime/LastAccessTime (or enumeration results) on a storage or stream whose STATSTG FILETIME fields are all zero — typical for storages created by writers that never set timestamps.","commonSituations":"Compound files produced by non-.NET tools or older writers that leave time fields zeroed; streams created programmatically and never committed with timestamps.","solutions":["Wrap timestamp reads in try/catch for NotSupportedException and fall back to DateTime.MinValue or File system times.","Check dwHighDateTime/dwLowDateTime availability via STATSTG before converting, if using the native layer directly.","Obtain timestamps from the containing file (FileInfo) when per-storage times are unavailable.","Regenerate the compound file with a writer that sets STATSTG times."],"exampleFix":"// before\nvar created = storageInfo.CreationTime; // throws NotSupportedException\n// after\nDateTime created;\ntry { created = storageInfo.CreationTime; }\ncatch (NotSupportedException) { created = DateTime.MinValue; }","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat per-storage timestamps as optional data.","Fall back to container-file timestamps when storage times are absent.","Regenerate files with writers that set STATSTG times when timestamps matter."],"tags":["io","compound-file","timestamp","not-supported"],"backgroundTag":"unsupported-operation","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}