I need to know if ther开发者_如何学JAVAe is any .NET API exists to fetch the current time from Internet Time Server, so that changing the system time at the client will not affect the integrity of my application.
you have several options - though none built-in:
- http://dotnet-snippets.com/dns/simple-network-time-ntp-protocol-client-SID571.aspx
- http://www.codeproject.com/KB/IP/ntpclient.aspx
- http://www.codeproject.com/KB/datetime/SNTPClient.aspx
- http://www.rebex.net/time.net/ (commercial)
There's a third party library that should bail you out. See the NtpClient class
For other alternatives, see the similar thread here
Ah - no. Simple like that. No NTP support.
You can use third party NTPClient.cs.
Example how to use:
DateTime time_nist_gov = NTPClient.GetTime().TransmitTimestamp; // uses NTPClient.DefaultTimeServer = "time.nist.gov"
DateTime time_windows_com = NTPClient.GetTime("time.windows.com").TransmitTimestamp;
DateTime pool_ntp_org = NTPClient.GetTime("pool.ntp.org").TransmitTimestamp;
精彩评论