UnauthorisedAccessException in c# UWP Application I am suddenly getting this error when trying to access files in LocalState. Haven't made any changes to code. Worked fine until this morning.
//in public class
Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
Windows.Storage.StorageFile pHSensorsFile;
public string[] pHSensorsArray;
//async void ReadSensors()
Task t = Task.Run(async () => { return pHSensorsFile = await localFolder.GetFileAsync("pHSensors.txt"); });
t.Wait();
//This throws the error:
pHSensorsArray = await File.ReadAllLinesAsync(pHSensorsFile.Path);
Error details: System.UnauthorizedAccessException: 'Access to the path C:\Users\Admin\AppData\Local\Packages\27924aef-1d51-48c2-9893-dace8724640c_snwgte540zp2r\LocalState\pHSensors.txt' is denied.'
I have tried re-opening the Solution, restarting VS2019. Has this happened to anyone else?