Windows Phone uses sharpcompress to decompress compressed files

Source: Internet
Author: User
Tags ziparchive

When doing the mobile side, when we need to obtain multiple files from the server, in order to save traffic, the server will generally return a compressed package, then we are the download completed, in the phone to extract to the specified location

Sharpcompress is the ability to unzip a class library (. net) in the phone, CodePlex is open source, supports desktop and mobile

Click to download the latest version view support Content API Usage Example

Let's take a look at the zip package used in the Windows Phone to unzip it

         Public Async voiddownloadanduncompress () {stringstrURL ="http://qd.baidupcs.com/file/3ebe6e988584733fba61c04e9568bc73?fid=3860865449-250528-923682234289515& Time=1401003314&sign=fdtaxer-dcb740ccc5511e5e8fedcff06b081203-sdvdhrr7p1ewhmufnoaylqbwlme%3d&to=qb &fm=q,b,u,nc&newver=1&expires=1401003914&rt=sh&r=347257022&logid=3996325361&sh=1 &vuk=3860865449&fn=sharpcompress0.10.3.zip"; awaitTask.run (() ={WebClient WC=NewWebClient (); Wc. OpenReadAsync (NewUri (strURL, Urikind.absolute)); Wc. DownloadProgressChanged+ = (s, dpce) = ={System.Diagnostics.Debug.WriteLine ("has been downloaded"+ DPCE. Progresspercentage +"%");                 }; Wc. Openreadcompleted+ = (s, orce) = =                 {                     if(Orce. Error! =NULL) {System.Diagnostics.Debug.WriteLine ("Download Error"); return; }                     using(IsolatedStorageFile storage =isolatedstoragefile.getuserstoreforapplication ()) {                         varziparchive = Archivefactory.open (orce. Result);//Create an decompressor                         foreach(varEntryinchZiparchive.entries)//extract inside each entity, including folders are counted entities                         {                             //If you first create a folder for a folder                             if(entry. isdirectory) {if(!storage. DirectoryExists (entry. FilePath)) {storage. CreateDirectory (entry.                                 FilePath); }                                 Continue; }                             //entry. FilePath the full path of the file                             using(IsolatedStorageFileStream Isofilestream =storage. CreateFile (entry. FilePath)) {//write to isolated storage spaceentry.                             WriteTo (Isofilestream);                         }} ziparchive.dispose (); System.Diagnostics.Debug.WriteLine ("Unzip complete");             }                 };        }); }

Others such as RAR, Tar, GZip, 7Zip can refer to CodePlex official documents

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.