Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 943
user3293835 Avatar asked Apr 28 '14 11:04

user3293835


Video Answer


2 Answers

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();
like image 143
meneses.pt Avatar answered Oct 15 '22 10:10

meneses.pt


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.

like image 30
StratocastFlo Avatar answered Oct 15 '22 11:10

StratocastFlo