locked
What is the catched exception when StorageFolder::GetFolderAsync() fails (C++)?

    Question

  • I want to have a sub folder of application data for my app storage. In App::OnLaunched, I do this :

     

    try {
    	create_task(localFolder->GetFolderAsync(L"anyname")).then([this](StorageFolder^ f) { 
    		m_dlyfolder = f; 
    	});
    }
    catch(...)
    {
    	try {
    		create_task(localFolder->CreateFolderAsync(L"anyname")).then([this](StorageFolder^ f){ 
    			m_dlyfolder = f; 
    		});
    	}
    	catch(...)
    	{
    		String^ msg = e->Message;
    		OutputDebugString(msg->Data());
    	}
    };

    It works well, creating the subfolder on first run and getting it on the next sessions.

    I would like to check which exceptions I get when CreateFolderAsync or GetFolderAsync fails, and it's not an Exception^.

    What should I put in the catch() instead of "..."? 

    Friday, June 15, 2012 9:22 AM

Answers

  • Hello,

    It is based on these code to get if the function success

                if (f)
                {
                    OutputTextBlock->Text = "Picked folder: " + folder->Name;
                }
                else
                {
                    OutputTextBlock->Text = "Operation cancelled.";
                }

    For the exception, you can customer the exception, please follow this document
    http://msdn.microsoft.com/en-us/library/windows/apps/dd997692(v=vs.110).aspx

    Best regards,
    Jesse


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

    • Marked as answer by Jesse Jiang Wednesday, June 27, 2012 9:34 AM
    Monday, June 18, 2012 11:42 AM