本文整理汇总了C#中System.DateTime.ToFileTime方法的典型用法代码示例。如果您正苦于以下问题:C# DateTime.ToFileTime方法的具体用法?C# DateTime.ToFileTime怎么用?C# DateTime.ToFileTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.ToFileTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FILETIME
/// <summary>
/// Builds a FILETIME structure using a DateTime value.
/// </summary>
/// <param name="dt">DateTime value used to initialize the FILETIME structure.</param>
public FILETIME ( DateTime dt )
{
ulong value = ( ulong ) dt. ToFileTime ( ) ;
__dwHighDateTime = ( uint ) ( ( value >> 32 ) & 0xFFFFFFFF ) ;
__dwLowDateTime = ( uint ) ( value & 0xFFFFFFFF ) ;
Value = ( ulong ) dt. ToFileTime ( ) ;
}
示例2: ZipFileInfo
public ZipFileInfo (DateTime fileTime)
{
date = new ZipTime (fileTime);
dosDate = new IntPtr ((int)fileTime.ToFileTime ());
internalFileAttributes = IntPtr.Zero;
externalFileAttributes = IntPtr.Zero;
}
示例3: WakeupTimer
public WakeupTimer(DateTime time, Action runAction)
{
_runAction = runAction;
var worker = new BackgroundWorker();
worker.DoWork += DoWork;
worker.RunWorkerCompleted += RunWorkerCompleted;
worker.RunWorkerAsync(time.ToFileTime());
}
示例4: DateTimeToFiletime
/// <summary>
/// Returns an equivalent <see cref="System.Runtime.InteropServices.ComTypes.FILETIME"/> of the <see cref="System.DateTime"/> object.
/// </summary>
/// <param name="dateTime">The date time.</param>
/// <returns></returns>
public static FILETIME DateTimeToFiletime( DateTime dateTime )
{
FILETIME ft;
long hFT1 = dateTime.ToFileTime();
ft.dwLowDateTime = (int) ( ( hFT1 << 32 ) >> 32 );
ft.dwHighDateTime = (int) ( hFT1 >> 32 );
return ft;
}
示例5: ToSystemTime
private Win32Native.SystemTime ToSystemTime(DateTime dateTime)
{
long fileTime = dateTime.ToFileTime();
var systemTime = new Win32Native.SystemTime();
if (!Win32Native.FileTimeToSystemTime(ref fileTime, systemTime))
Win32ErrorHelper.ThrowExceptionIfGetLastErrorIsNotZero();
return systemTime;
}
示例6: GenerateETag
private static string GenerateETag(DateTime lastModified, DateTime now) {
long num = lastModified.ToFileTime();
long num2 = now.ToFileTime();
string str = num.ToString("X8", CultureInfo.InvariantCulture);
if ((num2 - num) <= 0x1c9c380L) {
return ("W/\"" + str + "\"");
}
return ("\"" + str + "\"");
}
示例7: GenerateETag
public static string GenerateETag(DateTime lastModified, DateTime now)
{
long lastModifiledFileTime = lastModified.ToFileTime();
long dateNow = now.ToFileTime();
string str = lastModifiledFileTime.ToString("X8", CultureInfo.InvariantCulture);
if ((dateNow - lastModifiledFileTime) <= TimeSpan.TicksPerSecond) // There are 10 million ticks in one second.
{
return ("W/\"" + str + "\"");
}
return ("\"" + str + "\"");
}
示例8: SetWakeUpTime
public void SetWakeUpTime(DateTime time)
{
try
{
bgWorker.RunWorkerAsync(time.ToFileTime());
}
catch (Exception)
{
Log.AppLog.WriteEntry(this, Localise.GetPhrase("Background timer already running, cannot start another event"), Log.LogEntryType.Warning, true);
}
}
示例9: GenerateETag
private static string GenerateETag(HttpContext context, DateTime lastModified, DateTime now) {
// Get 64-bit FILETIME stamp
long lastModFileTime = lastModified.ToFileTime();
long nowFileTime = now.ToFileTime();
string hexFileTime = lastModFileTime.ToString("X8", CultureInfo.InvariantCulture);
// Do what IIS does to determine if this is a weak ETag.
// Compare the last modified time to now and if the difference is
// less than or equal to 3 seconds, then it is weak
if ((nowFileTime - lastModFileTime) <= 30000000) {
return "W/\"" + hexFileTime + "\"";
}
return "\"" + hexFileTime + "\"";
}
示例10: ConvertDateTime
//ExStart:ConvertDateTime
private static byte[] ConvertDateTime(DateTime t)
{
long filetime = t.ToFileTime();
byte[] d = new byte[8];
d[0] = (byte)(filetime & 0xFF);
d[1] = (byte)((filetime & 0xFF00) >> 8);
d[2] = (byte)((filetime & 0xFF0000) >> 16);
d[3] = (byte)((filetime & 0xFF000000) >> 24);
d[4] = (byte)((filetime & 0xFF00000000) >> 32);
d[5] = (byte)((filetime & 0xFF0000000000) >> 40);
d[6] = (byte)((filetime & 0xFF000000000000) >> 48);
d[7] = (byte)(((ulong)filetime & 0xFF00000000000000) >> 56);
return d;
}
示例11: Main
static void Main(string[] args)
{
Console.WriteLine(Win32ApiHelper.IsSystemResumeAutomatic());
DateTime lastBootUpTime = new DateTime();
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from win32_OperatingSystem");
foreach (ManagementObject queryObj in searcher.Get())
{
var timeStr = Convert.ToString(queryObj["LastBootUpTime"]);
Console.WriteLine(timeStr);
lastBootUpTime = ManagementDateTimeConverter.ToDateTime(timeStr);
Console.WriteLine(lastBootUpTime);
}
IntPtr status = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(long)));
Win32ApiHelper.CallNtPowerInformation(
Win32ApiHelper.POWER_INFORMATION_LEVEL.LastSleepTime,
(IntPtr)null,
0,
status,
(UInt32)Marshal.SizeOf(typeof(long))
);
long lastSleepTime = (long) Marshal.PtrToStructure(status, typeof(long));
Console.WriteLine(DateTime.FromFileTime(lastBootUpTime.ToFileTime() + lastSleepTime));
Win32ApiHelper.CallNtPowerInformation(
Win32ApiHelper.POWER_INFORMATION_LEVEL.LastWakeTime,
(IntPtr)null,
0,
status,
(UInt32)Marshal.SizeOf(typeof(long))
);
long lastWakeTime = (long)Marshal.PtrToStructure(status, typeof(long));
Console.WriteLine(DateTime.FromFileTime(lastBootUpTime.ToFileTime() + lastWakeTime));
}
示例12: BarData
/// <summary>
/// Construct empty BarData, for this dateTime.
/// </summary>
public BarData(DateTime dateTime)
{
_dateTime = dateTime.ToFileTime();
_volume = double.NaN;
_open = double.NaN;
_close = double.NaN;
_high = double.NaN;
_low = double.NaN;
isHigherPrev = false;
//_arrow = 0;
isCompleted = true;
//_stopLoss = 0;
//_gainTip = 0;
//_stopGain = 0;
sar = double.NaN;
cr = double.NaN;
isReverse = false;
rsi = double.NaN;
rsi2 = double.NaN;
rsi3 = double.NaN;
rsi4 = double.NaN;
actPrice = double.NaN;
stopLossPrice = double.NaN;
stopGainPrice = double.NaN;
signalList = new List<CandleSignal>();
exHigh = _high;
exLow = _low;
ar = double.NaN;
ar2 = double.NaN;
br = double.NaN;
cci = double.NaN;
cci2 = double.NaN;
cci3 = double.NaN;
indicators = new Dictionary<string, double>();
lwr = new Dictionary<string, double>();
wr = double.NaN;
wr2 = double.NaN;
lwr.Add(LWR.LWR1, 0);
lwr.Add(LWR.LWR2, 0);
boll = new Dictionary<string, double>();
boll.Add(BOLL.UPPER, 0);
boll.Add(BOLL.MID, 0);
boll.Add(BOLL.LOWER, 0);
}
示例13: DateTimeToLong
public static long DateTimeToLong(DateTime dt)
{
if (dt==DateTime.MinValue)
{
return 0;
}
else
{
try
{
return dt.ToFileTime();
}
catch
{
return 0;
}
}
}
示例14: Add
public void Add(HttpContent content, string name, string fileName, FileAttributes attributes, DateTime lastWriteTimeUtc)
{
if (content.Headers.ContentDisposition == null)
{
content.Headers.ContentDisposition = new ContentDispositionHeaderValue("dir-sync-data")
{
Name = name,
FileName = fileName,
FileNameStar = fileName,
};
var parameters = content.Headers.ContentDisposition.Parameters;
parameters.Add(new NameValueHeaderValue("fileAttributes", HttpUtility.UrlEncode(attributes.ToString())));
parameters.Add(new NameValueHeaderValue("lastWriteTimeUtc", lastWriteTimeUtc.ToFileTime().ToString(CultureInfo.InvariantCulture)));
}
base.Add(content);
}
示例15: PosTest1
public bool PosTest1()
{
bool retVal = true;
TestLibrary.TestFramework.BeginScenario("PosTest1: The current dateTime equals 1601/1/1");
try
{
DateTime date1 = new DateTime(1601, 1, 1).ToLocalTime().ToUniversalTime();
long result = date1.ToFileTime();
if (result != 0)
{
TestLibrary.TestFramework.LogError("001", "The ActualResult is not the ExpectResult");
retVal = false;
}
}
catch (Exception e)
{
TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
retVal = false;
}
return retVal;
}