本文整理汇总了C#中DateTimeOffset.ToFileTime方法的典型用法代码示例。如果您正苦于以下问题:C# DateTimeOffset.ToFileTime方法的具体用法?C# DateTimeOffset.ToFileTime怎么用?C# DateTimeOffset.ToFileTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTimeOffset
的用法示例。
在下文中一共展示了DateTimeOffset.ToFileTime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToFileTime
public static FILETIME ToFileTime(DateTimeOffset fileTime)
{
var lft = fileTime.ToFileTime();
FILETIME ft;
ft.dwLowDateTime = (int) (lft & 0xFFFFFFFF);
ft.dwHighDateTime = (int) (lft >> 32);
return ft;
}
示例2: TestConversion
public static void TestConversion()
{
DateTimeOffset today = new DateTimeOffset(DateTime.Today);
long dateTimeRaw = today.ToFileTime();
Assert.Equal(today, DateTimeOffset.FromFileTime(dateTimeRaw));
}
示例3: SetLastWriteTimeInternal
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);
}
}
}
示例4: ToFromFileTime
public static void ToFromFileTime()
{
var today = new DateTimeOffset(DateTime.Today);
long dateTimeRaw = today.ToFileTime();
Assert.Equal(today, DateTimeOffset.FromFileTime(dateTimeRaw));
}
示例5: LookupFileInfo
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;
}
示例6: SetTimes
public void SetTimes(string path, string accountName, DateTimeOffset modificationTime, DateTimeOffset accessTime)
{
_client.FileSystem.SetTimes(path, accountName, modificationTime.ToFileTime(), accessTime.ToFileTime());
}