how to call extraction function in background transfer download RRS feed

  • Question

  • hi

        I have used background download transfer to download zip files,i have called zipextraction function

    function DownloadOperation() { var download = null; var promise = null; this.start = function (uri, destFolder, fileName, priority, requestUnconstrainedDownload) { var ext = fileName.substr(fileName.lastIndexOf('.')); if (ext.localeCompare(".zip") != 0) { displayError("Invalid file type. Please make sure the file type is zip.", NotifyType.ErrorMessage); return; } // Asynchronously create the file in the pictures folder. destFolder.createFileAsync(fileName, Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (localFile) { var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader(); // Create a new download operation. download = downloader.createDownload(uri, localFile); Log("Downloading " + uri.absoluteUri.toString() + "to " + destFolder.name + "with " + priority + " priority, " + download.guid); download.priority = priority; // In this sample, we do not show how to request unconstrained download. // For more information about background transfer, please refer to the SDK Background transfer sample: // http://code.msdn.microsoft.com/windowsapps/Background-Transfer-Sample-d7833f61 if (!requestUnconstrainedDownload) { // Start the download and persist the promise to be able to cancel the download. promise = download.startAsync().then(complete, error, progress); promise.done(function () { if (download.progress.status === Windows.Networking.BackgroundTransfer.BackgroundTransferStatus.canceled) { LogStatus("Canceled: " + download.Guid, NotifyType.StatusMessage); return; }

    //zip extraction var zipFileName = fileName.substr(0, fileName.lastIndexOf('.')); destFolder.createFolderAsync(zipFileName, Windows.Storage.CreationCollisionOption.generateUniqueName).done(function (unzipFolder) { // Call C# compent to unzip the specified zipfile to a folder upZipFile(localFile, unzipFolder); }); }); return; } }, error); }; // On application activation, reassign callbacks for a download // operation persisted from previous application state. this.load = function (loadedDownload) { download = loadedDownload; promise = download.attachAsync().then(complete, error, progress); }; }

    when i restart my app getcurrentdownloadASync working fine,this.load function reassign the callbacks to download but where to call extraction method when i reattach my transfer download,how to pass the arguements to this.load() function

    Windows.Networking.BackgroundTransfer.BackgroundDownloader.getCurrentDownloadsAsync().done(function (downloads) {
                        // If downloads from previous application state exist, reassign callbacks and persist to global array.
                        if (downloads) {
                            Log("Loading background downloads: " + downloads.size);
                            console.log("download size:" + downloads.size);
                            for (var i = 0; i < downloads.size; i++) {
                                var download = new DownloadOperation();
    Any help would be greatly appreciated

    Thursday, May 1, 2014 4:54 AM


  • Hi Suganthe - can you do the extraction when the app starts?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, May 1, 2014 7:37 PM