user3293835
user3293835

Reputation: 899

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?

Upvotes: 5

Views: 8392

Answers (2)

StratocastFlo
StratocastFlo

Reputation: 81

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.

Upvotes: 2

meneses.pt
meneses.pt

Reputation: 2616

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();

Upvotes: 7

Related Questions