|
|||
|
By using the LiteZip, you can create zip files in swfkit pro.
First, add the LiteZip.dll into the "Resources" panel in swfkit pro Second, in the "initialize" script, define the functions in LiteZip.dll Code:
var LiteZip = getAdditionalFile("LiteZip.dll");
// creates a new zip file
// handle - returns a handle to the newly created zip file.
// With the handle we can add files into the zip file
// filename - the name of the zip file to create
// password - password for the zip file to create
dllimport LiteZip stdcall long ZipCreateFileA(long* handle, String filename, String password) as zipCreate;
// closes a zip file
dllimport LiteZip stdcall long ZipClose(long handle) as zipClose;
// adds a file into the zip file
// handle - the handle of the created zip file
// nameInZip - the name of the file after added into the zip file
// fileToAdd - the path name of a disk file to add
dllimport LiteZip stdcall long ZipAddFileA(long handle, String nameInZip, String fileToAdd) as zipAddFile;
// adds a folder to a zip file
dllimport LiteZip stdcall long ZipAddFolderA(long handle, String folderName) as zipAddFolder;
// adds a folder on disk into a zip file
// handle - the handle of the zip file to operate
// dirName - name of the directory on disk
// offset - from where the sub string of a file name on disk will be
// the name in the zip file. For example, to add the directory
// "c:\flash\test", in which there is a file "sample.pdf", if
// offset is length of the string "c:\flash\test\", the "sample.pdf"
// in the zip file will still be "sample.pdf"; however, if the
// offset is length of string "c:\flash\", the name of "sample.pdf" in
// zip file will be "test\sample.pdf", that is, it is in the "test"
// folder. Say the full path name of a disk file is strFullName, its
// name in zip is strZipName, then
//
// strZipName = strFullName.substring(offset);
dllimport LiteZip stdcall long ZipAddDirA(long handle, String dirName, long offset) as zipAddDir;
Code:
// creates a new zip file to get a handle var handle = new Object; handle.value = 0; zipCreate(handle, "c:\\flash\\1.zip", ""); // adds files zipAddFile(handle.value, "hi.txt", "c:\\flash\\hi.txt"); zipAddFile(handle.value, "myfiles\\readme.txt", "c:\\flash\\1.txt"); // adds an empty folder zipAddFolder(handle.value, "newfolder"); // adds files in a directory zipAddDir(handle.value, "c:\\flash\\test", "c:\\flash\\".length); // closes and saves the zip file zipClose(handle.value); |
|
|||
|
This looks great and will be a really helpful addition to pack files from my programs. Thanks for coming up with this solution.
I have one question - the above code looks like it saves the file to the C: drive. I haven't tried it yet, but will do so later on. Can I just check - is there a way to make sure the user can choose where to save the .zip file instead? I ask this because on a corporate network most users will not have the ability to save to their C: drive.
__________________
|
|
|||
|
Ah - sorry - I wasn't quite clear enough with this request.
It looks like this addition automatically saves files to the C: drive of the user's computer when then .zip file is created. Instead, is it possible to have some files stored in the resources section of SWFKit and a new file generated which are then all packaged up as a .zip and saved in the location the user chooses. This is what I need!
__________________
|
|
|||
|
Hi again.
I still cannot quite get this to work. I have a .zip file with lots of files in it already where I want to add an additional file. I could either recreate the entire .zip file or I could just add a file to the existing one. Code:
// get 3 files from the resources panel
var savedFile1 = new File(getAdditionalFile("example.swf"));
var savedFile2 = new File(getAdditionalFile("example.js"));
var savedFile3 = new File(getAdditionalFile("example.html"));
// fileLoad or Save?
// In the examples it shows fileOpen, but that doesn't make sense
var filename = Dialogs.fileSave("Zip files(*.zip)|*.zip|", "zip");
if (filename) {
// Generating .zip file
// creates a new zip file to get a handle
var handle = new Object;
handle.value = 0;
// create zip and add files
zipCreateFile(handle.value, filename, savedFile1);
zipAddFile(handle.value, filename, savedFile2);
zipAddFile(handle.value, filename, savedFile3);
// closes and saves the zip file
zipClose(handle.value);
}
What would be even better would be to have a standard .zip file from the resources panel that I just add two files to and then create the new .zip file.
__________________
|
|
|||
|
I think I've found the errors I've been making - I've now successfully been able to generate a .zip file using the following code:
Code:
// get the name for the saved .zip file
var filename = Dialogs.fileSave("Zip files(*.zip)|*.zip|", "zip");
if (filename) {
// Generating .zip file
// creates a new zip file to get a handle
var handle = new Object;
handle.value = 0;
zipCreate(handle, filename, "");
// grab a file from the resources panel
var file1 = getAdditionalFile("example.swf");
// zipAddFile
// adds files
zipAddFile(handle.value, filename, file1);
// closes and saves the zip file
zipClose(handle.value);
}
__________________
|
|
|||
|
Quote:
Thanks for tips . Bye SnakeMedia
__________________
Sorry I am deaf! I have problem with eys... Thanks! |
|
|||
|
I lost whole day to figure out something with LiteZip.dll. As a result my app creates zip and then it just gives an error message. I think, something gets wrong when adding files to the zip.
I'd very thankful to someone who can tell what is the easiest way to zip files or at least who could give a simple tutorial how to create a dll and call functions of that dll from flash. I've installed VisualBasic. Which programming language is best for creating ActiveX dll's? Or all of them are the same? And one more question. Can SWFKit call only ActiveX dll functions or it is also possible to import other dll files and call their functions? As far as I understand dll and Activex dll files are different. I hope someone will ray some light on this issue. P.S. it's possible to find any dll files on net and download them, but they don't give any information on available function and variables in dll files, is it possible to get those variables and informations from a dll? Thank you, Anar Selimhanov selimhanov@gmail.com |
|
|||
|
LiteZip is a normal dll, not an activex dll. Do you mean that you are trying to call it from VB? Perhaps you haven't import it correctly into VB?
If you don't have document of a dll, it would be very difficult to know how to use it. |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|