locked
AV exception threw from CreateDecoderFromFilename

    Question

  • Hi,

     

    I got the following exception in CreateDecodeFromFilename.

     

    First-chance exception at 0x7523277C in Direct2DApp1.exe: Microsoft C++ exception: Platform::AccessDeniedException ^ at memory location 0x0200D9E8. HRESULT:0x80070005

     

    Code:

    		DX::ThrowIfFailed(m_wicFactory->CreateDecoderFromFilename(path->Data(), nullptr, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &decoder));
    
    Path here is
    C:\Users\xxxx\Pictures\0.jpg which is a picture in my library. I can use this function correct if I put this file in my app's folder. I already checked picture library capability.
    Friday, November 16, 2012 9:31 AM

Answers

  • Hi Billy,

    The access denied exception is correct. Windows Store apps do not have access to the file system outside of their install and application data directories. They cannot directly access files in the pictures library.

    The library capabilities give the app brokered access to the libraries. This allows the app to request a StorageFolder or StorageFile for items in the library, which will be accessed through a broker process which can manipulate the file or open it and provide a stream to the application.

    Instead of using CreateDecoderFromFileName, take a look at CreateDecoderFromStream .

    --Rob

    Friday, November 16, 2012 4:20 PM
    Owner