ziparchive

How to use the .NET ZipArchive and ZipArchiveEntry classes to extract a file with a PASSWORD

99封情书 提交于 2019-12-12 04:43:18
问题 I am extracting the contents of a zip file with the following code: using(ZipArchive zipArchive = new ZipArchive(memoryStream)) { foreach (ZipArchiveEntry entry in zipArchive.Entries) { entry.ExtractToFile("extract.txt"); } } This works perfectly for those zip files which are not password protected, however, I need it to also work for those passwords which are password protected. I have seen other samples which can achieve what I want using other classes or other code but I find this way to

Zip4j Excluding Folders from Zip

无人久伴 提交于 2019-12-12 04:23:50
问题 I have a directory with some folders that should be skipped and not added to the target ZIP file. I marked them as hidden on Windows and I can query this attribute using Java code as follows: new File("C:\\myHiddenFolder").isHidden(); However, I don't know how to use this with the following Zip4j-based method to skip adding those respective directories: public File createZipArchive(String sourceFilePath) throws ZipException, IOException { ZipParameters zipParameters = new ZipParameters();

Using .NET ZipArchive to zip entire directories AS well as extra info

こ雲淡風輕ζ 提交于 2019-12-12 03:24:45
问题 I inherited some code that makes use of ZipArchive to save some information from the database. It uses BinaryFormatter to do this. When you look at the zip file with 7-zip (for example), you see a couple of folders and a .txt file. All is working well. I simply want to modify the code to also have a folder in the ZipArchive called "temp" that consists of files and folders under C:\temp. Is there an easy way to add a entry (ZipArchiveEntry?) that consist of an entire folder or the disc? I saw

RecursiveIteratorIterator: include directory and php files in zip

[亡魂溺海] 提交于 2019-12-12 02:38:00
问题 I have a script which ZIPS directories, but need to add *.php files also. Issue having is error is thrown when adding something like ../index.php. Error produced by script below is: Fatal error: Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(../index.php): failed to open dir: Not a directory' in /home/mathtest/public_html/trig/admin/save.php:23 Stack trace: #0 /home/mathtest/public_html/trig/admin/save.php(23): RecursiveDirectoryIterator->_

Recursive descent in zip files?

雨燕双飞 提交于 2019-12-12 02:29:51
问题 I am trying to recursively scan a bunch of zip files and I am using, of course, archive::zip. I would like to avoid expanding the archive's content in a temporary folder. I would like to be able to use something like (nearly-pseudo code): sub CALLMYSELFAGAIN ..... my @members = $currentZipFile->members(); while(my $member = pop @members){ if ($member->isTextFile()){ push @content, $member->contents(); }elsif(isZipFile($member->fileName())){ CALLMYSELFAGAIN($member); } The problem is, $member-

How to create ePub with System.IO.Compression.ZipArchive?

南笙酒味 提交于 2019-12-11 10:26:02
问题 I've written some code generating ePub archive using .NET 4.5 System.IO.Compression.ZipArchive. I need this to be part of a Portable Class Library (PCL), hence using a subset of .NET fx. I have issue with the mimetype file containing the magic 'application/epub+zip'. Having read the specs, I add that file first with no compression. Despite this care, the produced ePub archive isn't conforming to specs. Specs demand the content of the mimetype file should start at position 38. Mine starts at

Change the created date attribute on a file in a zip archive using PHP

不问归期 提交于 2019-12-11 07:17:34
问题 Is it possible to use the ZipArchive class in PHP to change the created date or modified date of a file inside of a zip file without writing the file to a disk and using touch on it and then adding the file to the zip again 回答1: No, this is not possible. The external attributes have nothing to do with the file modified time, which is stored before the external attributes. I've looked at all the compression libraries in PHP, and this is not possible. I would recommend using JSON instead, if

ZipArchive::close(): Read error: Is a directory

眉间皱痕 提交于 2019-12-11 06:38:19
问题 I'm trying to figure out this problem but I cannot imagine why it keeps happening. I'm adding files to a ZipArchive and when I try to close it, it get the error that the destination is a directory. But I'm pretty sure it is not. This is the code of the zip function: function create_zip($folder, $destination) { $valid_files = get_files($folder); if(count($valid_files)) { $zip = new ZipArchive(); if($zip->open($destination, ZIPARCHIVE::CREATE) !== true) { return false; } //add the files foreach

“Bad Gateway Error 502” when trying to download server-generated .zip file

╄→гoц情女王★ 提交于 2019-12-11 04:32:40
问题 I'm getting a "bad gateway error 502" when trying to download a server-generated .zip-file I've isolated the line that causes the error; it's: $zip->addFile($thumb->loadVersion($version['id']), $rank . "_" . $thumb->filename); Here's my code. My script loops through all the .jpg files users have uploaded, bundles them into one big .zip file, and sends download headers for the .zip file. function downloadGalleryZip() { $tmpfile = tempnam("tmp", "zip"); $zip = new ZipArchive(); $res = $zip-

PDF in PHP ZipArchive throwing errors, server permissions

风格不统一 提交于 2019-12-11 04:05:29
问题 I am collecting a number of files from the server and generating a ziparchive with PHP. All goes super well until I download the zip archive and try to open the file. The reader throws an exception "File type plain text document (text/plain) is not supported". The file is named correctly (c102.pdf). I presume the mime type of the file is getting messed up some how, but I'm not quite sure. php version 5.4.37 I should note that I'm using ubuntu 14.04 locally and my reader is the default