zipfile

How to Unzip all .Zip file from Folder using C# 4.0 and without using any OpenSource Dll?

江枫思渺然 提交于 2019-11-27 01:49:12
问题 I have a folder containing .ZIP files . Now, I want to Extract the ZIP Files to specific folders using C#, but without using any external assembly or the .Net Framework 4.5. I have searched, but not found any solution for unpacking *.zip files using Framework 4.0 or below. I tried GZipStream, but it only supports .gz and not .zip files. 回答1: Here is example from msdn. System.IO.Compression.ZipFile is made just for that: using System; using System.IO; using System.IO.Compression; namespace

python zipfile module doesn't seem to be compressing my files

柔情痞子 提交于 2019-11-27 01:13:20
问题 I made a little helper function: import zipfile def main(archive_list=[],zfilename='default.zip'): print zfilename zout = zipfile.ZipFile(zfilename, "w") for fname in archive_list: print "writing: ", fname zout.write(fname) zout.close() if __name__ == '__main__': main() The problem is that all my files are NOT being COMPRESSED! The files are the same size and, effectively, just the extension is being change to ".zip" (from ".xls" in this case). I'm running python 2.5 on winXP sp2. 回答1: This

python: Open file from zip without temporary extracting it

核能气质少年 提交于 2019-11-27 01:06:08
How can I open files from a zip archive without extracting them first? I'm using pygame. To save disk space, I have all the images zipped up. Is it possible to load a given image directly from the zip file? For example: pygame.image.load('zipFile/img_01') Jellema Vincent Povirk's answer won't work completely; import zipfile archive = zipfile.ZipFile('images.zip', 'r') imgfile = archive.open('img_01.png') ... You have to change it in: import zipfile archive = zipfile.ZipFile('images.zip', 'r') imgdata = archive.read('img_01.png') ... For details read the ZipFile docs here import io, pygame,

How to unzip a file with Python 2.4?

时光毁灭记忆、已成空白 提交于 2019-11-27 01:03:33
问题 I'm having a hard time figuring out how to unzip a zip file with 2.4. extract() is not included in 2.4. I'm restricted to using 2.4.4 on my server. Can someone please provide a simple code example? 回答1: You have to use namelist() and extract() . Sample considering directories import zipfile import os.path import os zfile = zipfile.ZipFile("test.zip") for name in zfile.namelist(): (dirname, filename) = os.path.split(name) print "Decompressing " + filename + " on " + dirname if not os.path

How do I add files to an existing zip archive

ⅰ亾dé卋堺 提交于 2019-11-26 23:09:08
问题 How can I add some file (almost always a single .csv file) to an existing zip file? 回答1: Since you are in .NET 4.5, you can use the ZipArchive (System.IO.Compression) class to achieve this. Here is the MSDN documentation: (MSDN). Here is their example, it just writes text, but you could read in a .csv file and write it out to your new file. To just copy the file in, you would use CreateFileFromEntry , which is an extension method for ZipArchive . using (FileStream zipToOpen = new FileStream(@

Create zip file: error running command “ ” had status 127

不想你离开。 提交于 2019-11-26 22:45:40
I am trying to create a zip file from multiple files using the zip function in r, but I keep getting this error message: running command '"zip" -r9X "data.zip" "dt1.txt" "dt2.txt" ' had status 127. How can I avoid that? setwd() dt1 <- sample(1:100, 10) dt2 <- sample(100:200, 10) write(dt1, "dt1.txt") write(dt2, "dt2.txt") zip('data.zip', files =c('dt1.txt', 'dt2.txt')) Here is how I solved this problem on my Windows 7 computer: Install Rtools from HERE . Locate the folder that Rtools is installed. In my case it is at C:\Rtools . Add C:\Rtools\bin path to the system path. Adding C:\Rtools\bin

Unzip and save files using as3?

廉价感情. 提交于 2019-11-26 21:51:19
问题 I have a list of zip and rar files in a local folder. All I need to do is to extract the contents of the zip as well as rar files and to save them in a folder with the same name of the respective archive file. Since I am new to as3, I have no clue for this. Is there any Library for this??? Thanks in advance... 回答1: There are a few libraries out there that deal with ZIP files in as3, but beware that this is no easy task for a beginner in ActionScript 3. FZip seems to be the most widely used,

why can't python unzip a password protected zip file created by winrar using the zip method?

笑着哭i 提交于 2019-11-26 21:03:37
问题 I have searched the web high and low but still couldn't find a solution for the above problem. Does anyone out there know why and if so how it can be done? psw="dg" ZipFile.extractall("data.zip", None, psw) The error that I've got: TypeError: unbound method extractall() must be called with ZipFile instance as first argument (got str instance instead) 回答1: Because you are using it wrong. :) From docs: ZipFile.extractall([path[, members[, pwd]]]) Extract all members from the archive to the

Adding folders to a zip file using python

末鹿安然 提交于 2019-11-26 19:14:28
问题 I want to create a zip file. Add a folder to the zip file and then add a bunch of files to that folder. So I want to end up with a zip file with a single folder with files in. I dont know if its bad practice to have folders in zip files or something but google gives me nothing on the subject. I started out with this: def addFolderToZip(myZipFile,folder): folder = folder.encode('ascii') #convert path to ascii for ZipFile Method for file in glob.glob(folder+"/*"): if os.path.isfile(file): print

Unzipping files in Python

混江龙づ霸主 提交于 2019-11-26 15:34:38
I read through the zipfile documentation , but couldn't understand how to unzip a file, only how to zip a file. How do I unzip all the contents of a zip file into the same directory? Rahul import zipfile with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref: zip_ref.extractall(directory_to_extract_to) That's pretty much it! user1741137 If you are using Python 3.2 or later: import zipfile with zipfile.ZipFile("file.zip","r") as zip_ref: zip_ref.extractall("targetdir") You dont need to use the close or try/catch with this as it uses the context manager construction. Use the extractall method,