locked
Need help by enumerate subfolders in the app's temporary folder.

    Question

  • Hello,

    I have this code to determine whether there is a specific subfolder:

    auto spFolder = ApplicationData::Current->TemporaryFolder;

    auto queryOptions = ref new QueryOptions(CommonFolderQuery::DefaultQuery);

    queryOptions->UserSearchFilter = ref new String(L"My Sub Folder");

    auto spResult = spFolder->CreateFolderQueryWithOptions(queryOptions);

    task<IVectorView<StorageFolder^>^>(spResult->GetFoldersAsync()).then([](IVectorView<StorageFolder^>^ spList)

    {

    if(spList->Size > 0)

    // ok, this folder exists

    else

    // create new folder here

    });

    The call of the GetFoldersAsync() fails with an exception "An invalid parameter was passed to a function that considers invalid parameters fatal.". If I take any Folder other than ApplicationData::Current->TemporaryFolder, then this code works.

    I ask for help.

    Best regards,

    Anry


    • Edited by AnryNetToo Thursday, June 07, 2012 9:22 AM
    Thursday, June 07, 2012 9:21 AM

Answers

  • Isn't it better to use something like:

    task<StorageFolder^>( Windows::Storage::ApplicationData::Current->TemporaryFolder->CreateFolderAsync( L"My Sub Folder", CreationCollisionOption::OpenIfExists)).then
    ([](StorageFolder^ folder)
    {
       // do something within my folder

    });

    Also you can change CreationCollisionOption to variable you need.


    Tuesday, June 12, 2012 5:09 PM

All replies

  •  

    Hello,

     

    I cannot reproduce your issue on Windows 8 Release Preview and Visual Studio 2012 RC.

     

    I would suggest you to change this environment to test it again.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Friday, June 08, 2012 5:00 AM
  • Isn't it better to use something like:

    task<StorageFolder^>( Windows::Storage::ApplicationData::Current->TemporaryFolder->CreateFolderAsync( L"My Sub Folder", CreationCollisionOption::OpenIfExists)).then
    ([](StorageFolder^ folder)
    {
       // do something within my folder

    });

    Also you can change CreationCollisionOption to variable you need.


    Tuesday, June 12, 2012 5:09 PM