Hello.
Encountered an error when using the following code:
private async void DB_Add_Drawing(object sender, RoutedEventArgs e)
{
try
{
...
var folderPicker = new FileOpenPicker();
folderPicker.CommitButtonText = "Select a file!";
folderPicker.ViewMode = PickerViewMode.Thumbnail;
folderPicker.SuggestedStartLocation = PickerLocationId.Desktop;
folderPicker.FileTypeFilter.Add(".pdf");
folderPicker.FileTypeFilter.Add(".jpeg");
folderPicker.FileTypeFilter.Add(".png");
StorageFile storageFile = await folderPicker.PickSingleFileAsync();
string Path = storageFile.Path;
StorageFile storageFile1 = await StorageFile.GetFileFromPathAsync(Path);
byte[] drawByte = await storageFile1.ReadBytesAsync();
...
}
catch(Exception ex)
{
...
}
}
This handler was created to get a file and write the path of the selected file to the SQL cell and in parallel write the file itself through transformations into a byte array to the next cell. But at the stage StorageFile storageFile1 = await StorageFile.GetFileFromPathAsync(Path); I'm getting the error [ System.UnauthorizedAccessException: 'Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))' ]. But why does this error occur if the file is selected via FileOpenPicker()? Is it necessary to declare Enterprise Authentication in the manifest? The selected file can be located anywhere on the disk (documents, desktop, and so on), as well as in a network folder.