Reputation: 18891
I want to load an image from C:\myFolder\myApp\logo.jpg
, but it doesn't load. There are no errors in VS's debugger, either.
I have tried
C:\myFolder\myApp\logo.jpg
and
file:///C:/myFolder/myApp/logo.jpg
and neither one loads anything. How can I use the file protocol in my WinJS app?
Upvotes: 0
Views: 96
Reputation: 7024
Use of the file protocol is not allowed by design, see How to Reference Content, https://msdn.microsoft.com/en-us/library/windows/apps/hh781215.aspx.
To reference arbitrary content on a user's hard drive requires user consent, and thus selection of arbitrary files and folder must necessarily go through the File Picker API, or if the user navigates to a folder and launches a file directly, an app could be launched with a reference to that file.
The only locations you can reference programmatically without consent (or another permission like the Pictures Library) are your appdata (local, roaming, and temp) locations, and the app package itself. See URI Schemes (https://msdn.microsoft.com/en-us/library/windows/apps/jj655406.aspx) for details on those.
Upvotes: 1