Access denied error when accessing usb stick files in Windows IoT core app

3

I want to access files (images, text files etc.) from an USB stick on my Raspberry Pi 2 using Windows 10 IoT Core.

So I've added the to the appxmanifest file.

When using this code in my IBackgroundTask I get an access denied error in the second line:

public sealed class StartupTask : IBackgroundTask
{
    public async void Run(IBackgroundTaskInstance taskInstance)
    {
    //...
        Windows.Storage.StorageFolder sf = Windows.Storage.KnownFolders.RemovableDevices;
        //get list of drives
        IReadOnlyList<Windows.Storage.StorageFolder> list = await sf.GetFoldersAsync();
    ...
    }
}

I found that I should add the fileTypeAssociation with the file types I'd like to access in Package.appxmanifest so I did that:

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" IgnorableNamespaces="uap mp iot">
  <Identity Name="test-uwp" Publisher="CN=user" Version="1.0.0.0" />
  <mp:PhoneIdentity PhoneProductId="8f31dff8-3a2b-4df1-90bb-2c5267f32980" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
  <Properties>
    <DisplayName>test</DisplayName>
    <PublisherDisplayName>user</PublisherDisplayName>
    <Logo>Assets\StoreLogo.png</Logo>
  </Properties>
  <Dependencies>
    <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
  </Dependencies>
  <Resources>
    <Resource Language="x-generate" />
  </Resources>
  <Applications>
    <Application Id="App">
      <uap:VisualElements DisplayName="test" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="test" BackgroundColor="transparent" AppListEntry="none">
        <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
        </uap:DefaultTile>
        <uap:SplashScreen Image="Assets\SplashScreen.png" />
      </uap:VisualElements>
      <Extensions>
        <Extension Category="windows.backgroundTasks" EntryPoint="test.StartupTask">
          <BackgroundTasks>
            <iot:Task Type="startup" />
          </BackgroundTasks>
        </Extension>
        <uap:Extension Category="windows.fileTypeAssociation">
          <uap:FileTypeAssociation Name="myimages">
            <uap:SupportedFileTypes>
              <uap:FileType ContentType="image/jpeg">.jpg</uap:FileType>
            </uap:SupportedFileTypes>
          </uap:FileTypeAssociation>
        </uap:Extension>
      </Extensions>
    </Application>
  </Applications>
  <Capabilities>
    <Capability Name="internetClient" />
    <uap:Capability Name="removableStorage" />
  </Capabilities>
</Package>

If I want to deploy that, I get the following error:

Severity Code Description Project File Line Suppression State Error Error : DEP0700 : Registration of the app failed. AppxManifest.xml(37,10): error 0x80070490: Cannot register the test-uwp_1.0.0.0_arm__yzekw4x8qxe1g package because the following error was encountered while parsing the windows.fileTypeAssociation Extension element: Element not found. . Try again and contact the package publisher if the problem persists. (0x80073cf6)

As soon as I remove the uap:Extension element, the error goes away (but the access denied is still there).

Did I miss anything? Is it not possible to access files from an USB stick using a background service (I want to run that headless with no user interaction)?

raspberry-pi2
windows-10-iot-core
windowsiot
asked on Stack Overflow Jan 12, 2016 by kcode

1 Answer

2

At the moment you can't register a headless app that uses filetypeAssociation. There is a workaround - see here: https://github.com/ms-iot/ntvsiot/issues/62

Simply add a headed app (project) to your solution (no need for any special code there). Add a reference to this project in your headless app.

Now change the manifest of the headless (file asso..) and add Executable: YourHeadedApp.exe and EntryPoint: YourHeadedApp.App now with the next deploy the EXE will be included in deployment - so it can be found when the manifest is checked.

answered on Stack Overflow Feb 20, 2016 by ManniAT • edited Feb 20, 2016 by ManniAT

User contributions licensed under CC BY-SA 3.0