WebFile.SaveAsync never returns

Jan 21, 2013 at 9:28 PM
Edited Jan 21, 2013 at 9:31 PM

I am trying to use the WebFile.SaveAsync method to retrieve a small user profile picture, in this case mine for testing, but the call to SaveAsync never returns, I have lifted the code from the sample project where it works, but in mine it does not.  Below is the method:

        private static async void GetProfilePicture()
        {

            var file = await WinRTXamlToolkit.Net.WebFile.SaveAsync(new Uri("https://cid-3a7dff108e388999.users.storage.live.com/users/0x3a7dff108e388999/myprofile/expressionprofile/profilephoto:UserTileStatic"), ApplicationData.Current.LocalFolder);

            if (file != null)
                await new Windows.UI.Popups.MessageDialog("Downloaded file. Name determined: " + file.Name).ShowAsync();
        }
The Url of the image is hardcoded at the moment just to prove that it was not an issue with the property holding the value.
I am calling this from another method that is declared as private async Task ...
Any help on this appreciated.
Cheers,
Rupert.
Coordinator
Jan 21, 2013 at 9:41 PM

Your method doesn't return a Task, so it is not awaitable and is only usable as a sort of fire and forget call. Perhaps you need to enable some app capabilities (Internet client?) in the app manifest? Other than that - I don't know what might be wrong. This worked fine for me and showed the file name to be "profilephoto", which seems to be a jpg file, even though it is not advertized as one.

                var file = await WinRTXamlToolkit.Net.WebFile.SaveAsync(new Uri("https://cid-3a7dff108e388999.users.storage.live.com/users/0x3a7dff108e388999/myprofile/expressionprofile/profilephoto:UserTileStatic"), ApplicationData.Current.LocalFolder);
                if (file != null)                    await new Windows.UI.Popups.MessageDialog("Downloaded file. Name determined: " + file.Name).ShowAsync();