Purpose Read a zip file GuiXT has no built-in support for zip files, so you need to call a JavaScript , VBScript or VB.NET function. Here we show the JavaScript solution. |
Solution
// unzip the file into a
temporary folder // display test message with content of target directory Message "&text[msg]" |
JavaScript functionfunction unzip(zipfile, parentfolder) { // create shell opbject var sh = guixt.CreateObject("Shell.Application"); var zip = sh.NameSpace(zipfile); if (!zip) { alert("File " + zipfile + " not found"); return ""; }; // files contained in zip file var src = zip.Items(); // parent folder var par = sh.NameSpace(parentfolder); // create temp folder var tempfolder = "temp." + Math.random(); par.NewFolder(tempfolder); var trg = sh.NameSpace(parentfolder + "\\" + tempfolder); // copy files trg.CopyHere(src); // wait since shell copy is done asynchronously while (src.count != trg.Items().count) { guixt.DoEvents() }; // free objects trg = null; src = null; sh = null; return parentfolder + "\\" + tempfolder; }; |
Components |