简体   繁体   中英

How to access downloads folder in windows phone 8.1

I want to download files to Downloads folder and read. it is a root folder like photos and videos.

But Windows.Storage.DownloadsFolder isn't available for phone and I don't see it in KnownFolders like Windows.Storage.KnownFolders.PicturesLibrary;

Also I tried C:\\Data\\Users\\Public\\Downloads\\ it gives an unauthorized result.

I see some apps has access to it, but how?

You can use a file or folder picker. I'm not sure if you want the user to chose a file, or if you want to pick a file yourself, but i think the best way to achieve this is using something like:

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.SuggestedStartLocation = PickerLocationId.Downloads;
StorageFile file = await openPicker.PickSingleFileAsync();

or

FolderPicker folderPicker = new FolderPicker();
folderPicker.SuggestedStartLocation = PickerLocationId.Downloads;
folderPicker.PickFolderAndContinue();

To complete the previous answer, it is possible to access such a folder, but only after a first access to it through FolderPicker.

The trick is to use the StorageApplicationPermissions.FutureAccessList. It is what file explorers applications do. It will give you a token that you can save in your IsolatedStorage, so you can later access the Downloads folder directly, thanks to the token.

See there for a walkthrough with StorageApplicationPermissions.mostRecentlyUsedList : http://msdn.microsoft.com/library/windows/apps/hh972603 but the principles are quite the same with FutureAccessList.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM