Access denied. HRESULT exception: 0x80070005 on Windows Phone 8.1

I am developing a Windows Phone 8.1 Silverlight application,

I am trying to download a document from an SD card but am getting this error.

Access is denied. Exception from HRESULT: 0x80070005
System.UnauthorizedAccessException

I also added the "ID_CAP_REMOVABLE_STORAGE" feature in the WMAppManifest file. But does not work.

See my code below:

private async void UploadDocument()
{
  StorageFolder externalDevices = KnownFolders.RemovableDevices;

  StorageFolder sdCard = (await externalDevices.GetFoldersAsync()).FirstOrDefault();

  if (sdCard != null)
  {
      //An SD card is present and the sdCard variable now contains a reference to it
  }

  else
  {
      // No SD card is present.
  }
}
+4
source share
1 answer

WP8.1 also has a new manifest file - Package.appxmanifest - make sure you also add features there - Location. You will also need to add a file type association like Silverlight.

( , ) - Package.appxmanifest → View code , , "/":

<Extension Category="windows.fileTypeAssociation">
  <FileTypeAssociation Name="text">
    <DisplayName>Text file</DisplayName>
    <SupportedFileTypes>
      <FileType ContentType="text/file">.txt</FileType>
    </SupportedFileTypes>
  </FileTypeAssociation>
</Extension>

/ FileTypeAssociations .

+4

Source: https://habr.com/ru/post/1569680/


All Articles