Can't save to text file with universal app

Kenne76

New member
Joined
Jun 2, 2016
Messages
4
Programming Experience
3-5
I can't save any changes to the text file settings.txt , but reading the file works.
The code is
private async void LedShow_Loaded(object sender, RoutedEventArgs e)
{
var path = @"settings.txt";
var folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
var file = await folder.GetFileAsync(path);
var lines = await Windows.Storage.FileIO.ReadLinesAsync(file);
sliderDelay.Value = Convert.ToInt32(lines[0]);
textBlockDelayValue.Text = lines[0] + " seconds";
buttonSave.IsEnabled = false;
}
and the error message is

An exception of type 'System.UnauthorizedAccessException' occurred in System.Private.CoreLib.dll but was not handled in user code
Access is denied. (Excep_FromHResult 0x80070005) occurred
Can someone help me?
 
Sounds like your application doesn't have permission to write to the folder it is located. Try checking the permissions on the folder and settings.txt file (if it already exists) or try running the application as an administrator.

Sent from my SM-G935P using Tapatalk
 
Back
Top Bottom