My project is almost ready now. To check if the app is launched for the first time, I am accessing the local folder of the application in the App.OnLaunched()
function and setting a new value if it is null. The code inside the conditional statement seems to execute properly as the app works fine on the subsequent runs. Can anyone help to workaround this problem and see if the app can be run for the first time without crashing?
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
if (localSettings.Values["waslaunched"]==null)
{
//Code for first launch
localSettings.Values["waslaunched"] = "launched";
}
//Other autogenerated code in OnLaunched()
}
Debugger shows the following exception System.UnauthorizedException: Access Is Denied