locked
Problem while calling Create/GetFolderAsync() method

    Question

  • Hi all,

    I am suffering a problem with following code:

    create_task(Windows::ApplicationModel::Package::Current->InstalledLocation->CreateFolderAsync("XML")).then([this](StorageFolder^ folder)
    {
    });

    or:

    create_task(Windows::ApplicationModel::Package::Current->InstalledLocation->GetFolderAsync("XML")).then([this](StorageFolder^ folder){});

    The code can be successfully built, but always throws exception:

    An invalid parameter was passed to a function that considers invalid parameters fatal.

    Any one here knows how the invalid parameter exception comes and give me some suggestion here? Thank you.

    Wednesday, November 07, 2012 2:43 PM

Answers

All replies

  • Hi  goldkyo,

    In your case you can create folder under Application data folder.
    http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx

    Because application not having full privilege in Installed Location.

    please see this thread -
    http://social.msdn.microsoft.com/Forums/en-CA/winappswithnativecode/thread/7ac233cc-9e0b-42cd-a483-49cebf7fff97

    thanks,
    Bhash

    • Marked as answer by goldkyo Thursday, November 22, 2012 4:17 PM
    Wednesday, November 07, 2012 7:48 PM
  • Hi BhashTech,

    Thank you for your help, your way works for the problem I was facing. But now I am suffering another problem with the following code:

    create_task(Windows::Storage::ApplicationData::Current->LocalFolder->CreateFolderAsync(L"XML", CreationCollisionOption::OpenIfExists)).then([this, folderCode](StorageFolder^ folder) ->IAsyncOperation<StorageFile^>^
    {
    return folder->CreateFileAsync(L"recent_list.xml", CreationCollisionOption::OpenIfExists);
    }).then([this](StorageFile^ file)->IAsyncOperation<XmlDocument^> ^{
    return XmlDocument::LoadFromFileAsync(file);
    }).then([this](XmlDocument^ doc){
    mXMLDocument = doc;
    });

    The code above can be built successfully as well, but it is being executing, part of them will not be executed which is following:

            }).then([this](StorageFile^ file)->IAsyncOperation<XmlDocument^> ^{
    return XmlDocument::LoadFromFileAsync(file);
    }).then([this](XmlDocument^ doc){
    mXMLDocument = doc;
    });

    Does any one knows what is wrong with those code? I do appreciate your help.

    Wednesday, November 21, 2012 3:24 PM