windows store app 8.1 file system access - windows-store-apps

Can windows store apps only access "library" files and not other locations on the hard drives of PCs? Like if I had a D drive that was full of video media that I wanted the app to have access to, is there no way to get to that? I've been searching for a while now and can't find anything but "knownfolder" examples and documentation.

In order to access files outside of the libraries and other specific locations, you'd need to use the FileOpenPicker or FolderPicker. You can find more information on File Access and Permissions for Windows Store apps at http://msdn.microsoft.com/en-us/library/windows/apps/Hh967755.aspx.

Related

How to deploy resource files for a windows store app

I am working on a windows store app, one of the workflows within the app would allow the user to export a report in html format. The html report relies on a css file so I would like to ensure that the install process could deploy the file in a local folder. If not I would need to read out the file from the assets folder (within the install bundle) and manually write it out but that seems pretty kludgy
https://learn.microsoft.com/en-us/uwp/api/Windows.Storage.KnownFolders?view=winrt-22000
mentions that "The Documents library is not intended for general use." so would require use through file picker but I would prefer to be able to export the document without user intervention without additional store approval headaches (apparently adding Documents library capability to manifest requires additional Microsoft store approval).
Questions
When I create files within the store app it seems the location options are limited and I can only write to Localfolder (which is actually hidden and users cannot easily get to it) - There must be a way to create a file within the MyDocuments directory that is easily accessible by users but looks like that is off limits to a windows store app? So what is the best approach to write reports to storage that can be easily accessed by users
How can one deploy files to a specific directory during install time? Assuming there are some installer commands/manifest directives that would allow this capability?
Or maybe there is a entirely different mechanism to allow for this functionality within the store app and I am just looking in all the wrong places...

Windows store app access file system

I'm developing a Windows store app and need to display files in user computer like in file explorer. Everywhere it says windows store apps only access "library" files and not other locations on the hard drives of PC. And I don't mean something like FileOpenPicker, I want to show file on may application like explorer.
What is the library I should use? System.IO class missing those methods on store apps. I know it is possible. Cos I have seen many applications in store has done that. Few examples are
https://www.microsoft.com/en-us/store/apps/file-browser/9wzdncrfj29m
https://www.microsoft.com/en-us/store/apps/my-explorer/9wzdncrfj0lm
Thanks in advance
Apps like the ones you mention typically use a FolderPicker to let the user pick the root of the file system and then remember that permission in a FutureAccessList for later use.
Your research was correct: apps cannot get general access to the file system. APps can declare access to the libraries, and app have automatic access to their local data, but anywhere else requires user permission via a picker or equivalent. See File access permissions on MSDN.

Directory sandboxed access for Google Drive / Dropbox API / RemoteStorage apps?

Is there a way to get sandboxed, user-selected directory access on any major file service without first getting read level access to their entire filesystem?
There's a lot of talk about "unhosted" static webapps that allow users to access their data from a 3rd party file service (Google Drive, Dropbox, their own server, etc.). The most notable effort I've found so far is remoteStorage.io, but there doesn't seem to be a way with any major provider to let the user select a directory and then use that as a sandbox without breaking their trust (i.e. getting read access to all their files first).
From the user's perspective, the webapp shouldn't have access to anything else on the remote file storage except the one folder the user grants it access to (for example, I might grant a text editor access to my FunnyJokes folder).
The current work around seems to be having the webapp force a specific folder name ahead of time ("this app wants access to /appname_notes"), but that rules out letting the user point it to where they may already have their notes.
Does anyone know of a nice way to do this with Google Drive, Dropbox, or the like?
The user experience that makes the most sense to me is something like...
User opens an unhosted webapp (for example, a basic text editor TextyApp). They click a button to connect with their data.
3rd party auth page appears (for example, Google Drive) and it says "The app TextyApp has requested read/write access to your files. Please select a directory to use."
Confirmation screen: "Grant read/write access to folder FunnyJokes for TextyApp?"
The page redirects back to the webapp with sandboxed accessed to the user-specified folder and the files within it.
This seems like how remote file storage should work, but I haven't found a way to do it yet. Any thoughts/suggestions would be great!
Cheers,
Adam
Edit: To clarify, I'm not talking about storing hidden "application data", but instead letting the user specify a particular directory to sandbox for use with a webapp that they may not want to give broader access to.
The Dropbox Apps API provides the ability to restrict any app using your API key to a single directory of your Dropbox account. So users could create an API key with access to a specific directory and then plug that into your app. However, that's not a user-friendly workflow.
I think the Dropbox Drop-Ins Chooser/Saver API might be close to what you want. The user is presented with a Dropbox file selection popup, and your app only gets access to the specific file(s) that the user selects.
With remoteStorage, sandboxed directory access is currently the default way for apps to request (and users to grant) access to the storage. However, users cannot manually select or enter custom directories during the connect phase.

WinJS - How to access whole folder tree without FolderPicker

I'm building a Store App using WinJS and I need to create a structure with some info related the user's tree folder (every drive, not only C:), is there any way to get the whole Folder structure from every drive without using the File/FolderPicker?
No, by design Windows Store Apps run inside an app container that limits what they're allowed to do without user consent. The only areas of storage that are openly accessible without further consent are the app's package location (which is read-only, see [Windows.ApplicationModel.Package.Current.installedLocation][1]) and its app data folders (see Windows.Storage.ApplicationData).
If the app declares library access in its manifest (for Pictures, Videos, and Music), these are noted on the app's page in the Store such that the act of installing the app amounts to user consent. There is also a RemovableStorage library that's similar, but for that you have to declare specific file types.
If an app is registered for a file type association in its manifest, and the user launches the app through a file, that grants access.
Beyond this, the way you get access to any other storage location is through the pickers. However, if you have the user pick once, you can save that consent by saving the StorageFolder into the Windows.Storage.AccessCache API, so that you can open the folder again in an future app session without having to reacquire consent.
For all the details of this, refer to the first section of Chapter 11, "The Story of State, Part 2: User Data," of my free ebook, Programming Windows Store Apps with HTML, CSS, and JavaScript, Second Edition.

Can I store app properties without a file?

I am familiar with the regular properties APIs for storing app-specific metadata to a file, but is there any way I can store App metadata within drive without linking it to a specific file?
I would prefer to store some configuration settings, but the only approach I've seen for this so far has been to create an actual file in GDrive (and hope the user doesn't delete it).
Is there a more stable approach?
You can store a configuration in you Application Data Folder on Google Drive.
More infos in the actual documentations, but a quick explanation is that you can store files in an hidden folder visible only by your application (any application using the same api key share the same AppData folder).
For example I store a text file with the settings of an Android application, when the user installs it on a different device, the settings are downloaded to the new device.
The approach using a file to store settings let you keep track of the changes made on the configuration by using versions, but if you are more keen to use properties, you can still create an empty app.config file and store properties on it.