I'm trying to create a folder structure within My Pictures folder from a Windows store app. But I can't seem to get pass the first level.
I create my first level folder using the following code:
IAsyncOperation<StorageFolder> appFolder = Windows.Storage.KnownFolders.PicturesLibrary.GetFolderAsync("AppPhotos");
if (appFolder==null)
{
//Create folder
appFolder = Windows.Storage.KnownFolders.PicturesLibrary.CreateFolderAsync("AppPhotos");
}
Now I want to create another folder below this call Level1.
I was expecting to be able to do the following:
appFolder.CreateFolderAsync("Level1");
But I don't have a CreateFolderAsync method from my appFolder.
So, how can I create that Folder and then how would I then select it?
Thanks in advance
I'm using Visual Studio 2012, C#4.5, XAML and I'm writing a windows store app.
To create a folder and a subFolder in picture library:
You seem to have missed the async/await revolution there and assume the operation to get a folder is a folder. This should work:
You also need to add the
async
keyword in the method signature wherever the above code is located and then also if your method returns a value of typeT
- change it to returnTask<T>
, so for method signature:you would change it to
and if your current signature is
you would need to do
Finally in that last case - you would need to also change your calls from
to
etc. marking all methods that make calls that await other methods with the
async
keyword.