Exemple #1
0
        private async void Download()
        {
            String Token = await StorageInterface.ReadFromLocalFolder("Storage.Garfield.token");

            if (Token == null || Token.Equals(""))
            {
                await UserInteraction.ShowDialogAsync("INFORMATION", "You will now be prompted to chose a Folder in which to save the Comic. This App will create a new Folder within the Folder you selected, called \"Garfield\", which will be used to store the images (in order not to confuse them with your files). The App will remember the location you have picked and will use this location until you change it in the Settings.");

                Token = await StorageInterface.PickExternalStorageFolder();

                await StorageInterface.WriteToLocalFolder("Storage.Garfield.token", Token);
            }
            try
            {
                await StorageInterface.WriteBytesToKnownFolder("Garfield/Garfield_" + date.ToString("yyyy_MM_dd") + ".gif", await NetworkInterface.DownloadGarfield(date), Token);
            }
            catch (Exception e)
            {
                e.PrintStackTrace();
                UserInteraction.ShowToast("ERROR! Could not save file.", "Garfield");
                return;
            }
            UserInteraction.ShowToast("Comic has successfully been saved", "Garfield");
        }