zipfile

Zip entry name ends in directory separator character but contains data

折月煮酒 提交于 2019-12-01 07:55:25
问题 System.IO.Compression.ZipFile.ExtractToDirectory(zipPath, extractPath); Using ZipFile in C#, I'm trying to extract a file from a known location and it is throwing the following error: System.IO.Exception: Zip entry name ends in directory separator character but contains data I've done some research, ExtractToDirectory is explained in MSDN but couldn't find this error definition. Would you be able to explain why this error is happening? From MSDN: IOException The directory specified by

How to handle unzipping ZipFile with paths that are too long/duplicate

删除回忆录丶 提交于 2019-12-01 03:19:09
When unzipping files in Windows, I'll occasionally have problems with paths that are too long for Windows (but okay in the original OS that created the file). that are "duplicate" due to case-insensitivity Using DotNetZip, the ZipFile.Read(path) call will crap out whenever reading zip files with one of these problems. Which means I can't even try filtering it out. using (ZipFile zip = ZipFile.Read(path)) { ... } What is the best way to handle reading those sort of files? Updated: Example zip from here: https://github.com/MonoReports/MonoReports/zipball/master Duplicates: https://github.com

How to handle unzipping ZipFile with paths that are too long/duplicate

痞子三分冷 提交于 2019-11-30 23:47:09
问题 When unzipping files in Windows, I'll occasionally have problems with paths that are too long for Windows (but okay in the original OS that created the file). that are "duplicate" due to case-insensitivity Using DotNetZip, the ZipFile.Read(path) call will crap out whenever reading zip files with one of these problems. Which means I can't even try filtering it out. using (ZipFile zip = ZipFile.Read(path)) { ... } What is the best way to handle reading those sort of files? Updated: Example zip

Extract files with invalid characters in filename with Python

风流意气都作罢 提交于 2019-11-30 23:27:29
I use python's zipfile module to extract a .zip archive (Let's take this file at http://img.dafont.com/dl/?f=akvaleir for example.) f = zipfile.ZipFile('akvaleir.zip', 'r') for fileinfo in f.infolist(): print fileinfo.filename f.extract(fileinfo, '.') Its output: Akval�ir_Normal_v2007.ttf Akval�ir, La police - The Font - Fr - En.pdf Both files are unaccessable after extraction because there are invalid encoded characters in their filenames. The problem is zipfile module doesn't have an option to specify output filenames. However, "unzip akvaleir.zip" escapes the filename well: root@host:~#

How can I pass a Python StringIO() object to a ZipFile(), or is it not supported?

主宰稳场 提交于 2019-11-30 23:13:38
问题 So I have a StringIO() file-like object, and I am trying to write it to a ZipFile(), but I get this TypeError: coercing to Unicode: need string or buffer, cStringIO.StringI found Here is a sample of the code I am using: file_like = StringIO() archive = zipfile.ZipFile(file_like, 'w', zipfile.ZIP_DEFLATED) # my_file is a StringIO object returned by a remote file storage server. archive.write(my_file) The docs say that StringIO() is a file-like class and that ZipFile() can accept a file-like

Unzipping a password protected file in Node.js

空扰寡人 提交于 2019-11-30 22:31:07
问题 Is there a library that I can use to unzip a password protected file (Site makes me put a password on the file when downloading it)? There are a ton of libraries to unzip normal files, but none that I can find that will do it with a password. Here I found some helpful starters. But I would rather not resort to using child_process and using built in unix unzipping functionality, but that may be my last resort. I would even be up to preforming my own manipulation on the encrypted code, but I'm

Php create zip file (from post attachments wordpress)

三世轮回 提交于 2019-11-30 21:29:17
I am trying to create a zip file from post attachments in wordpress . I have tried both methods below - but it results in nothing (No error messages , no file created) - What am I doing wrong (again .. ) I do not think that The fact that those are post attachments in wordpress has anything to do with it - because those methods failed also with normal files . why ? --> See the answer . $files_to_zip = array();// create files array //run a query $post_id = get_the_id(); $args = array( 'post_type' => 'attachment', 'numberposts' => null, 'post_status' => null, 'post_parent' => $post_id );

Convert a VERY LARGE binary file into a Base64String incrementally

大兔子大兔子 提交于 2019-11-30 18:54:53
I need help converting a VERY LARGE binary file (ZIP file) to a Base64String and back again. The files are too large to be loaded into memory all at once (they throw OutOfMemoryExceptions) otherwise this would be a simple task. I do not want to process the contents of the ZIP file individually, I want to process the entire ZIP file. The problem: I can convert the entire ZIP file (test sizes vary from 1 MB to 800 MB at present) to Base64String, but when I convert it back, it is corrupted. The new ZIP file is the correct size, it is recognized as a ZIP file by Windows and WinRAR/7-Zip, etc., and

Unzip file from zip archive of multiple files using ZipFile class

痞子三分冷 提交于 2019-11-30 15:21:22
I'd like to use the ZipFile class to unzip a file using its name from an archive of multiple files. How can I get the string of the zip file name and directory to pass to the ZipFile constructor? You can use the AssetManager and ZipInputStream http://developer.android.com/reference/android/content/res/AssetManager.html ZipInputStream in = null; try { final String zipPath = "data/sample.zip"; // Context.getAssets() in = new ZipInputStream(getAssets().open(zipPath)); for (ZipEntry entry = in.getNextEntry(); entry != null; entry = in.getNextEntry()) { // handle the zip entry } } catch

Python: Getting files into an archive without the directory?

时光总嘲笑我的痴心妄想 提交于 2019-11-30 14:56:55
问题 I've been learning python for about 3 weeks now, and I'm currently trying to write a little script for sorting files (about 10.000) by keywords and date appearing in the filename. Files before a given date should be added to an archive. The sorting works fine, but not the archiving It creates an archive - the name is fine - but in the archive is the complete path to the files. If i open it, it looks like: folder1 -> folder2 -> folder3 -> files . How can I change it such that the archive only