Reputation: 2265
everyone. I want to access a .wav file from my Assets folder in a UWP app, as follow:
StorageFile file = await Package.Current.InstalledLocation.GetFileAsync(@"ms-appx:///Assets/"+"sound.wav");
but I get the following error:
UWP accessing file System.UnauthorizedAccessException: Access is denied.
I though I did everything right as described in MSDN, but I get the error still.
Upvotes: 2
Views: 943
Reputation: 2383
Use either
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/"+"sound.wav"));
or
StorageFile file = await Package.Current.InstalledLocation.GetFileAsync(@"Assets\"+"sound.wav");
Upvotes: 1