/// <summary> /// Set the data from the raw values provided. /// </summary> /// <param name="data">The raw data to extract values from.</param> /// <param name="index">The index to start extracting values from.</param> /// <param name="count">The number of bytes available.</param> public void SetData(byte[] data, int index, int count) { using (var ms = new MemoryStream(data, index, count, false)) using (var helperStream = new ZipHelperStream(ms)) { helperStream.ReadLEInt(); // Reserved while (helperStream.Position < helperStream.Length) { var ntfsTag = helperStream.ReadLEShort(); var ntfsLength = helperStream.ReadLEShort(); if (ntfsTag == 1) { if (ntfsLength >= 24) { var lastModificationTicks = helperStream.ReadLELong(); _lastModificationTime = DateTime.FromFileTime(lastModificationTicks); var lastAccessTicks = helperStream.ReadLELong(); _lastAccessTime = DateTime.FromFileTime(lastAccessTicks); var createTimeTicks = helperStream.ReadLELong(); _createTime = DateTime.FromFileTime(createTimeTicks); } break; } else { // An unknown NTFS tag so simply skip it. helperStream.Seek(ntfsLength, SeekOrigin.Current); } } } }
/// <summary> /// Set the data from the raw values provided. /// </summary> /// <param name="data">The raw data to extract values from.</param> /// <param name="index">The index to start extracting values from.</param> /// <param name="count">The number of bytes available.</param> public void SetData(byte[] data, int index, int count) { using (var ms = new MemoryStream(data, index, count, false)) using (var helperStream = new ZipHelperStream(ms)) { // bit 0 if set, modification time is present // bit 1 if set, access time is present // bit 2 if set, creation time is present _flags = (Flags)helperStream.ReadByte(); if (((_flags & Flags.ModificationTime) != 0) && (count >= 5)) { var iTime = helperStream.ReadLEInt(); _modificationTime = (new DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime() + new TimeSpan(0, 0, 0, iTime, 0)).ToLocalTime(); } if ((_flags & Flags.AccessTime) != 0) { var iTime = helperStream.ReadLEInt(); _lastAccessTime = (new DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime() + new TimeSpan(0, 0, 0, iTime, 0)).ToLocalTime(); } if ((_flags & Flags.CreateTime) != 0) { var iTime = helperStream.ReadLEInt(); _createTime = (new DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime() + new TimeSpan(0, 0, 0, iTime, 0)).ToLocalTime(); } } }