Asked by:
Does "Folder enumeration sample" work in a folder for which capability cannot be declared

Question
-
We are porting our in-house desktop app to Windows store app to take advantage of new gestures of input (touch and penstyle). The app is expected to read and visualize data files stored in a folder on a mapped network drive (e.g. Z:\data), just like browsing photos one by one in the picture library folder. I tried the Windows 8 "Folder enumeration sample", but this sample only works in a folder for which we can declared capability in package.appxmanifest file. This controdicts the comments written in description.html:
"This sample shows how to enumerate the top-level files and folders inside a location (like a folder, device, or network location), and how to use queries to enumerate all files inside a location by sorting them into file groups."
So we need to programmatically get a sorted list of all files of a given folder. If this feature cannot be implemented, then I am afraid there is little change to deploy Windows store version of our app in our company. Maybe we may turn to Android to see if it is feasible, but most of us preferred Windows 8/RT. Could someone help? thank.
Wednesday, December 19, 2012 4:36 PM
All replies
-
How are you accessing the z:\data folder? Folder enumeration should work if the user grants access through the FolderPicker, but your app won't have access to the folder by default. Once the user grants access the first time the app can cache that access to enumerate the StorageFile unprompted later.
I discuss several points related to working within the sandbox in Skip the path: stick to the StorageFile
--Rob
Wednesday, December 19, 2012 8:11 PMModerator -
How are you accessing the z:\data folder? Folder enumeration should work if the user grants access through the FolderPicker, but your app won't have access to the folder by default. Once the user grants access the first time the app can cache that access to enumerate the StorageFile unprompted later.
I discuss several points related to working within the sandbox in Skip the path: stick to the StorageFile
--Rob
- Edited by Leonard Thursday, December 20, 2012 12:49 AM
Thursday, December 20, 2012 12:48 AM -
That won't work. If the user grants you access to the file then you have access only to that file. You cannot access other arbitrary files that you don't have access to.
For what you describe you should use the FolderPicker to have the user choose the folder their files are in.
--Rob
Thursday, December 20, 2012 1:34 AMModerator -
That won't work. If the user grants you access to the file then you have access only to that file. You cannot access other arbitrary files that you don't have access to.
For what you describe you should use the FolderPicker to have the user choose the folder their files are in.
--Rob
- Edited by Leonard Thursday, December 20, 2012 2:46 AM
Thursday, December 20, 2012 2:45 AM -
That won't work. If the user grants you access to the file then you have access only to that file. You cannot access other arbitrary files that you don't have access to.
For what you describe you should use the FolderPicker to have the user choose the folder their files are in.
--Rob
We come up with a walkaround to this issue and hope it may work.
We may add an option in my app to let user select a folder that holds all their files through a FolderPicker. It makes sense since the data folder is fixed (e.g. Z:\data). In this way we get a StorageFolder object representing Z:\data (say m_RootFolder).
In our case, given a file (e.g. Z:\data\subdir1\file1.hdf) and its associated StorageFile object (say m_file), we hope to use m_RootFolder.GetFolderFromPathAsync(m_file.Path) function to obtain the deepest folder (Z:\data\subdir1) and its associated StorageFolder object (say m_file1Folder). Finaly we call m_file1Folder.GetFilesAsync() to get the file list and do a search to find the next file of Z:\data\subdir1\file1.hdf.
Thursday, December 20, 2012 11:50 AM