Daniel
Daniel

Reputation: 23

How to use an UWP Application on Raspberry PI to set the SystemTime

I get an exception if i run this Code on a RPI with W10iotCore:

Windows.System.DateTimeSettings.SetSystemDateTime(new DateTime(sometime));

like

System.UnauthorizedAccessException: Access is denied.

I understand this exception but how can I run this Code with the Access to change the DateTime of the System?

That means on the debug Version in VisualStudion (still on the rpi) and the Normal runtime Environment of the App.

The Background: I am Building a weatherstation with the possibility to not have an Internet connection. For the time Setting I will use an DCF77 Receiver for setting the SystemTime on Startup or the updateability on clicking a Button.

Upvotes: 2

Views: 218

Answers (1)

Matt Johnson-Pint
Matt Johnson-Pint

Reputation: 241420

This function requires the "System Management" capability, which you can set in your appxmanifest.

screenshot

See here and here.

Upvotes: 1

Related Questions