locked
FileNotFoundException when using a ms-appdata Uri (DIRECT2D/WINRT)

    Question

  • Dear,

    I'm trying to draw some images.

    The problem I have is that when using an image from the Assets folder, the images are drawn perfectly. But when I use an image from the ms-appdata:///local/... folder I receive a FileNotFoundException...(I've double checked and the image is really there ;) )

    The failing CreateDecoderFromFilename method in Codesnippet:

    void TestControl::DrawLogo(Platform::String ^ logo, Windows::Foundation::Rect rect) { ComPtr<IWICBitmapDecoder> pDecoder = NULL; DX::ThrowIfFailed(m_pIWICFactory->CreateDecoderFromFilename( logo ->Data(), NULL, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &pDecoder ));

    //Other image rendering funtions...

    I have no idea what is going wrong here. Could you help me out please?

    Regards,

    Annihil8
    Tuesday, April 30, 2013 2:09 PM

Answers

  • What is the path name you are passing to CreateDecoderFromFilename? Are you passing the ms-appdata:///local/... URI or are you converting that to an actual path? I expect CreateDecoderFromFilename requires a file system path and not a URI.

    The thread BillKrat linked doesn't look relevant: that thread was about trying to open a file from a location the app didn't have direct access to, but apps have direct access to their local app data and in that scenario we'd get access denied rather than file not found.

    --Rob

    • Marked as answer by Annihil8 Wednesday, May 1, 2013 10:32 PM
    Wednesday, May 1, 2013 10:14 PM
    Owner

All replies

  • The following message thread may hold the answer to your question:

    http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/b5e80a8f-25c4-4e20-876b-e783dc6c3c5e


    MCAD.NET C# - http://www.Global-webnet.com/Blog

    Tuesday, April 30, 2013 2:32 PM
  • What is the path name you are passing to CreateDecoderFromFilename? Are you passing the ms-appdata:///local/... URI or are you converting that to an actual path? I expect CreateDecoderFromFilename requires a file system path and not a URI.

    The thread BillKrat linked doesn't look relevant: that thread was about trying to open a file from a location the app didn't have direct access to, but apps have direct access to their local app data and in that scenario we'd get access denied rather than file not found.

    --Rob

    • Marked as answer by Annihil8 Wednesday, May 1, 2013 10:32 PM
    Wednesday, May 1, 2013 10:14 PM
    Owner
  • Hi Rob!

    You have pointed me in the right direction ;)
    At first I was pointing to the ms-appdata:///local... uri.
    Now I switched to just passing the filename only and concatinate a new path by using

    String^ logo = ApplicationData::Current->LocalFolder->Path +"/"+ logoFileName;
    This works perfectly!

    Regards,
    Annihil8
    Wednesday, May 1, 2013 10:32 PM