Indeed, the sandbox has many limitations in where you can read from/write to. Here are some typical locations:
If you are trying to load resources from your application's installation folder, you can use the following:
(It is a read-only folder, so you cannot edit or create new files.)
If you are trying to write data files to your application's data folder, you can use the following:
(This folder is read-write. You can also access roaming or temporary folders by changing local to one of the other two.)
There are some other folders as well, such as the DownloadsFolder
, although you can only access files that your application downloads.
Alternatively, you can always ask the user for permission with FileOpenPicker
and FileSavePicker
. The pickers do not allow access to the InstalledLocation
path, but will allow you to access Documents
, Pictures
, and Downloads
(even if your app did not download the file).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…