locked
GetFolderFromPathAsync failed.

    Question

  • Hi All, i use a folderpicker to get a StorageFolder and send the StorageFolder->path to the dll, this dll is used both in desktop & metro app, so i want use the path as input parameter, the sample codes like this:

    create_task(folderPicker->PickSingleFolderAsync()).then([this](StorageFolder^ folder)
    {
     String^ folder_path = folder->Path;
     create_task(StorageFolder::GetFolderFromPathAsync(folder_path)).then([this](StorageFolder ^ folder2)
     {
      if (folder2)
      {
       OutputTextBlock->Text = "open file: " + folder2->Name + "\n";
      }
     });
    });

    is there any other way to solve this issue? thanks!


    • Edited by bszbrf Friday, July 06, 2012 4:02 AM
    Friday, July 06, 2012 4:01 AM

Answers

  • The GetFolderFromPathAsync API may be failing due to the permissions for the path you are passing to it (the directory selected from the FolderPicker). Note the StorageFolder->Path may not always be populated. See the Remarks section for the StorageFolder->Path documentation.


    David Lamb

    • Proposed as answer by Jesse Jiang Tuesday, July 10, 2012 7:18 AM
    • Marked as answer by bszbrf Thursday, July 12, 2012 2:54 AM
    Monday, July 09, 2012 9:03 PM
    Moderator

All replies

  • Hi,

    You should use nested .then() in order to catch the correct exception.

    auto pickFolderTask = create_task((folderPicker->PickSingleFolderAsync()).then([this](StorageFolder^ folder)
    {
     String^ folder_path = folder->Path;

    return StorageFolder::GetFolderFromPathAsync(folder_path);

    }).then([this](StorageFolder ^ folder2)

    {

     if (folder2)
      {
       OutputTextBlock->Text = "open file: " + folder2->Name + "\n";
      }
     });

    });

    This should help you with diagnosis of the error.

    -Sagar

    Monday, July 09, 2012 8:54 PM
    Moderator
  • The GetFolderFromPathAsync API may be failing due to the permissions for the path you are passing to it (the directory selected from the FolderPicker). Note the StorageFolder->Path may not always be populated. See the Remarks section for the StorageFolder->Path documentation.


    David Lamb

    • Proposed as answer by Jesse Jiang Tuesday, July 10, 2012 7:18 AM
    • Marked as answer by bszbrf Thursday, July 12, 2012 2:54 AM
    Monday, July 09, 2012 9:03 PM
    Moderator
  • the app will popup a exception dialog, error message is "An invalid parameter was passed to a function that considers invalid parameters fatal."  it may be caused by permission of metro file system. so I have to try using the StorageFolder^ as the input parameter of the dll. thanks Sagar B.Joshi & DavlidLamb.
    Tuesday, July 10, 2012 2:18 AM