Answered by:
Get storagefolder from path

Question
-
Hello,
i picked a folder using folderpicker and i need a subfolder or same folder by it's path is it possible with GetFolderFromPathAsync method ? when i using this method it through a exception
StorageFolder fo = null; private async void Pick_Click(object sender, RoutedEventArgs e) { FolderPicker fp = new FolderPicker(); fp.SuggestedStartLocation = PickerLocationId.ComputerFolder; fp.FileTypeFilter.Add("*"); StorageFolder folder = await fp.PickSingleFolderAsync(); fo = await StorageFolder.GetFolderFromPathAsync(folder.Path); }
exception
An exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll but was not handled in user code
WinRT information: Cannot access the specified file or folder (D:\Test\New folder). The item is not in a location that the application has access to (including application data folders, folders that are accessible via capabilities, and persisted items in the StorageApplicationPermissions lists). Verify that the file is not marked with system or hidden file attributes.
Please Help me...
Santana George
Monday, October 22, 2012 6:03 PM
Answers
-
why open it again this way?
but if you really want you will have to cache the acces with:http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.accesscache.aspx
- Edited by Dave SmitsMVP Monday, October 22, 2012 6:31 PM
- Marked as answer by Santana George Tuesday, October 23, 2012 12:50 AM
Monday, October 22, 2012 6:28 PM -
As described in the error text, you can only call GetFolderFromPathAsync for paths that the app can access natively. Your app cannot read d:\test, so it cannot directly access the folder.
Since you already have the folder returned from the picker why do you need to reopen it by path? Also consider that not all folders are backed by the file system and may not have a path at all.
As Dave (and the error) says, if the goal is to be able to open the same folder at some later date then you can cache access with the AccessCache namespace. See the File picker sample and File access sample for examples.
--Rob
- Marked as answer by Santana George Tuesday, October 23, 2012 12:50 AM
Monday, October 22, 2012 7:14 PMModerator
All replies
-
why open it again this way?
but if you really want you will have to cache the acces with:http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.accesscache.aspx
- Edited by Dave SmitsMVP Monday, October 22, 2012 6:31 PM
- Marked as answer by Santana George Tuesday, October 23, 2012 12:50 AM
Monday, October 22, 2012 6:28 PM -
As described in the error text, you can only call GetFolderFromPathAsync for paths that the app can access natively. Your app cannot read d:\test, so it cannot directly access the folder.
Since you already have the folder returned from the picker why do you need to reopen it by path? Also consider that not all folders are backed by the file system and may not have a path at all.
As Dave (and the error) says, if the goal is to be able to open the same folder at some later date then you can cache access with the AccessCache namespace. See the File picker sample and File access sample for examples.
--Rob
- Marked as answer by Santana George Tuesday, October 23, 2012 12:50 AM
Monday, October 22, 2012 7:14 PMModerator