Thursday, November 24, 2016

Can't save to text file with visual c# universal app.

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.Installed Location;
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?


from Windows Central Forums http://ift.tt/2gqHOgQ
via IFTTT

No comments:

Post a Comment