Question : Problems with zipfile

I've tried using zipfile under Python 2.4, WIn2003 Server. I can successfully add to an existing zip file, but cannot create a new one that works. I found a thread elsewhere that said there were problems with zipfile under later versions of Python.

import zipfile
zip = zipfile.ZipFile('c:/foo'.zip', 'w', 8)
zip.write('c:/foo'.txt')
zip.close()
del zip
 
The zip file shows up but it appears empty to WinZip and to Win2003 compressed folder.

Answer : Problems with zipfile

ramrom: Could you cut and paste the exact code you used to reproduce the problem?  The code in your question contains syntax errors.  For what it's worth, this:

import zipfile
zip = zipfile.ZipFile('c:/foo.zip', 'w', 8)
zip.write('c:/foo.txt')
zip.close()
del zip

works for me using python.org Python 2.4.2 on Windows XP SP2 (that is, it creates a zip file that WinZip can read).

Are you using 2.4.2?  If not, upgrading should be your next step.

You said "I found a thread elsewhere" - how about a URL?
Random Solutions  
 
programming4us programming4us