public static FILETIME ToFileTime(DateTimeOffset fileTime)
 {
     var lft = fileTime.ToFileTime();
     FILETIME ft;
     ft.dwLowDateTime = (int) (lft & 0xFFFFFFFF);
     ft.dwHighDateTime = (int) (lft >> 32);
     return ft;
 }
Example #2
0
    public static void TestConversion()
    {
        DateTimeOffset today = new DateTimeOffset(DateTime.Today);

        long dateTimeRaw = today.ToFileTime();
        Assert.Equal(today, DateTimeOffset.FromFileTime(dateTimeRaw));
    }
Example #3
0
 private static void SetLastWriteTimeInternal(string fullPath, DateTimeOffset time, bool asDirectory)
 {
     using (SafeFileHandle handle = OpenHandle(fullPath, asDirectory))
     {
         bool r = Interop.mincore.SetFileTime(handle, lastWriteTime: time.ToFileTime());
         if (!r)
         {
             throw Win32Marshal.GetExceptionForLastWin32Error(fullPath);
         }
     }
 }
Example #4
0
        public static void ToFromFileTime()
        {
            var today = new DateTimeOffset(DateTime.Today);

            long dateTimeRaw = today.ToFileTime();
            Assert.Equal(today, DateTimeOffset.FromFileTime(dateTimeRaw));
        }
        public bool LookupFileInfo()
        {
            _fileInfo = _options.FileProvider.GetFileInfo(_subPath.Value);
            if (_fileInfo.Exists)
            {
                _length = _fileInfo.Length;

                DateTimeOffset last = _fileInfo.LastModified;
                // Truncate to the second.
                _lastModified = new DateTimeOffset(last.Year, last.Month, last.Day, last.Hour, last.Minute, last.Second, last.Offset);

                long etagHash = _lastModified.ToFileTime() ^ _length;
                _etag = new EntityTagHeaderValue('\"' + Convert.ToString(etagHash, 16) + '\"');
            }
            return _fileInfo.Exists;
        }
 public void SetTimes(string path, string accountName, DateTimeOffset modificationTime, DateTimeOffset accessTime)
 {
     _client.FileSystem.SetTimes(path, accountName, modificationTime.ToFileTime(), accessTime.ToFileTime());
 }