替换方法
改用windowsAPI获取
[DllImport("kernel32.dll", EntryPoint = "GetSystemTime", SetLastError = true)] internal static extern void GetSystemTime(out SYSTEMTIME st); [DllImport("kernel32.dll", EntryPoint = "GetLocalTime", SetLastError = true)] internal static extern void GetLocalTime(out SYSTEMTIME st); /// <summary> /// 获取时间戳 /// </summary> /// <returns></returns> public static DateTime Now() { try { SYSTEMTIME time; TimeHelper.GetLocalTime(out time); DateTime now = new DateTime(time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond); return now; } catch { return DateTime.Now; } } [StructLayout(LayoutKind.Sequential)] public struct SYSTEMTIME { public short wYear; public short wMonth; public short wDayOfWeek; public short wDay; public short wHour; public short wMinute; public short wSecond; public short wMilliseconds; }