我做了一个flash桌面应用程序,要求用户将文件保存到他的计算机,在这种情况下我有很多图像,我希望用户将它们保存在他的计算机上,图像位于一个名为“ imgs“,我在这种情况下使用一个图像,我尝试使用FZip执行以下操作:
import deng.fzip.*;
import flash.filesystem.*;
import flash.filesystem.File;
//retrieve the image from the "imgs" folder
var myfile:File = new File("C:/Users/User/Desktop/zip/imgs/myimage.png");
//zipping the image
var zip:FZip = new FZip();
zip.addFile(myfile.name, myfile.data);
//saving the image to the user's desktop
var ba:ByteArray = new ByteArray();
zip.serialize(ba);
ba.position = 0;
var finalZIP:File = File.desktopDirectory.resolvePath("myfile.zip");
var fs:FileStream = new FileStream();
fs.open(finalZIP, FileMode.WRITE);
fs.writeBytes(ba);
fs.close();
结果是桌面上的一个zip文件,名为“myfile.zip”,并且图像名为“myimage.png”,但当我解压缩文件图像为空时,我试图用文本做同样的事情文件,文本文件是拉链的,但内部没有任何内容。 知道什么可能导致这个问题吗?