本文整理汇总了C#中System.DateTime.ToFileTimeUtc方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.ToFileTimeUtc方法的具体用法?C# DateTime.ToFileTimeUtc怎么用?C# DateTime.ToFileTimeUtc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.ToFileTimeUtc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Attach
public void Attach(byte[] streamId, byte[] streamIdToAttach, DateTime expiresAt)
{
if (ByteArrayHelper.Compare(streamId, streamIdToAttach))
throw new ArgumentException("Attaching a stream to itself is now allowed.");
var stream = repository.Load(streamId);
var result = stream.Attach(streamIdToAttach, expiresAt.ToFileTimeUtc());
if (result.IsSuccessful)
repository.AttachStream(streamId, streamIdToAttach, expiresAt.ToFileTimeUtc());
}
示例2: GetFileMd5
public static string GetFileMd5(string fileName, DateTime modified)
{
fileName += modified.ToFileTimeUtc();
char[] fileNameChars = fileName.ToCharArray();
byte[] buffer = new byte[_stringEncoder.GetByteCount(fileNameChars, 0, fileName.Length, true)];
_stringEncoder.GetBytes(fileNameChars, 0, fileName.Length, buffer, 0, true);
return BitConverter.ToString(_md5CryptoProvider.ComputeHash(buffer)).Replace("-", string.Empty);
}
示例3: EncodeUtcTime
public sealed override byte[] EncodeUtcTime(DateTime utcTime)
{
long ft = utcTime.ToFileTimeUtc();
unsafe
{
return Interop.Crypt32.CryptEncodeObjectToByteArray(CryptDecodeObjectStructType.PKCS_UTC_TIME, &ft);
}
}
示例4: DateTimeToFILETIME
static FILETIME DateTimeToFILETIME(DateTime time)
{
FILETIME ft;
var value = time.ToFileTimeUtc();
ft.dwLowDateTime = (int)(value & 0xFFFFFFFF);
ft.dwHighDateTime = (int)(value >> 32);
return ft;
}
示例5: DateTimeToFiletime
public static FILETIME DateTimeToFiletime(DateTime time)
{
FILETIME ft;
long hFT1 = time.ToFileTimeUtc();
ft.dwLowDateTime = (uint)(hFT1 & 0xFFFFFFFF);
ft.dwHighDateTime = (uint)(hFT1 >> 32);
return ft;
}
示例6: DateTimeToFiletime
/// <summary>
/// Converts DateTime to Win32 FileTime format
/// </summary>
public static Win32FileTime DateTimeToFiletime( DateTime time )
{
Win32FileTime ft;
var fileTime = time.ToFileTimeUtc( );
ft.DateTimeLow = ( uint ) ( fileTime & 0xFFFFFFFF );
ft.DateTimeHigh = ( uint ) ( fileTime >> 32 );
return ft;
}
示例7: ToFileTimeStructureUtc
public static FILETIME ToFileTimeStructureUtc(DateTime dateTime)
{
var value = dateTime.ToFileTimeUtc();
return new FILETIME
{
dwHighDateTime = unchecked((int)((value >> 32) & 0xFFFFFFFF)),
dwLowDateTime = unchecked((int)(value & 0xFFFFFFFF))
};
}
示例8: Detach
public void Detach(byte[] streamId, byte[] streamIdToDetach, DateTime detachedSince)
{
if (ByteArrayHelper.Compare(streamId, streamIdToDetach))
throw new ArgumentException("Detaching a stream from itself is now allowed.");
var stream = repository.Load(streamId);
var result = stream.Detach(streamIdToDetach, detachedSince);
if (result.IsSuccessful)
repository.DetachStream(streamId, streamIdToDetach, detachedSince.ToFileTimeUtc());
}
示例9: MessageLocation
/// <summary>
/// Create a path to queue for the given <paramref name="peer"/> and <paramref name="messageQueuedTime"/>.
/// </summary>
/// <param name="peer">The peer to build the path for.</param>
/// <param name="messageQueuedTime">The message file time to build a path for.</param>
/// <returns>A path to queue for the given <paramref name="peer"/> and <paramref name="messageQueuedTime"/>.</returns>
public static string MessageLocation(IPeer peer, DateTime messageQueuedTime)
{
var messageLocation = string.Format(
CultureInfo.InvariantCulture,
"/{0}/queue/{1}",
peer.EscapePeerAddress(),
messageQueuedTime.ToFileTimeUtc());
return messageLocation;
}
示例10: WaitThenDoStuff
public static void WaitThenDoStuff(DateTime time, Action stuff)
{
Task.Run(() =>
{
IntPtr timer = NativeMethods.CreateWaitableTimer(IntPtr.Zero, 1, null);
long abs_utc_time = time.ToFileTimeUtc();
NativeMethods.SetWaitableTimer(timer, ref abs_utc_time, 0, IntPtr.Zero, IntPtr.Zero, 1);
NativeMethods.WaitForSingleObject(timer, NativeMethods.INFINITE);
stuff();
});
}
示例11: IsValidValue
public static bool IsValidValue(DateTime value)
{
var flag = true;
try
{
value.ToFileTimeUtc();
}
catch
{
flag = false;
}
return flag;
}
示例12: Encode
private static byte[] Encode(DateTime signingTime)
{
long val = signingTime.ToFileTimeUtc();
System.Security.Cryptography.SafeLocalAllocHandle handle = System.Security.Cryptography.CAPI.LocalAlloc(0x40, new IntPtr(Marshal.SizeOf(typeof(long))));
Marshal.WriteInt64(handle.DangerousGetHandle(), val);
byte[] encodedData = new byte[0];
if (!System.Security.Cryptography.CAPI.EncodeObject("1.2.840.113549.1.9.5", handle.DangerousGetHandle(), out encodedData))
{
throw new CryptographicException(Marshal.GetLastWin32Error());
}
handle.Dispose();
return encodedData;
}
示例13: IsValidValue
public static bool IsValidValue(DateTime value)
{
bool result = true;
try
{
value.ToFileTimeUtc();
}
catch
{
result = false;
}
return result;
}
示例14: FILETIME
/// <summary>
/// Creates a new instance of the FILETIME struct.
/// </summary>
/// <param name="dateTime">A <see cref="DateTime"/> object to copy data from.</param>
public FILETIME(DateTime dateTime)
{
// Get the file time as a long in Utc
//
long fileTime = dateTime.ToFileTimeUtc();
// Copy the low bits
//
dwLowDateTime = (DWORD)(fileTime & 0xFFFFFFFF);
// Copy the high bits
//
dwHighDateTime = (DWORD)(fileTime >> 32);
}
示例15: DataTimeTransfer
public void DataTimeTransfer(ref long dataTimeValue)
{
DateTime dtServerTime = new DateTime(2016, 2, 8);
DateTime dtFromClient = DateTime.FromFileTimeUtc(dataTimeValue);
if (dtServerTime == dtFromClient)
{
dataTimeValue = dtServerTime.ToFileTimeUtc();
}
else
{
dataTimeValue = -1;
}
}