سؤال

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top