Unzip and save files using as3?

I have a list of zip and rar files in a local folder.
All I have to do is extract the contents of the zip as well as the rar files and save them in a folder with the same name of the corresponding archive file.
Since I'm new to as3, I have no clue for this.
Is there a library for this ???




Thanks in advance...

+5
source share
2 answers

There are several libraries that work with ZIP files in as3, but beware that this is not an easy task for a newbie to ActionScript 3.

, !

+6

zip , AS3Commons Zip ( FZip). Adler32, .

, zip-. , URLLoader zip Event.COMPLETE:

import org.as3commons.zip.Zip;
import org.as3commons.zip.ZipFile;

private function _onZipDownloaded(e:Event):void {

    var ba:ByteArray = ByteArray(e.target.data);
    var zip:Zip = new Zip();
    zip.loadBytes(ba);

    for(var i:uint = 0; i < zip.getFileCount(); i++) {

        var zipFile:ZipFile = zip.getFileAt(i);
        var extracted:File = directory.resolvePath(zipFile.filename);

        var fs:FileStream = new FileStream();
        fs.open(extracted, FileMode.WRITE);
        fs.writeBytes(zipFile.content);
        fs.close();

    }

}

, ​​ , ...

+10

All Articles