rzed wrote: > I create a zip file on my WinXP system, using this function: > > <fn> > import zipfile > import os > import os.path > > def zipdir(dirname, zfname): > zf = zipfile.ZipFile(zfname, 'w', zipfile.ZIP_DEFLATED) > for root, dirs, files in os.walk(dirname): > for f in files: > fullname = os.path.join(root, f) > zf.write(fullname) > zf.close() > </fn> > > The file is created, and, again using zipfile, I can read it and > extract from it and so on. > > Has anyone else observed this? If not, is there something in the > code that I should change to permit XP to view the contents?
A couple of guesses: - If dirname is an absolute path then you are including the drive specifier in the path in the zip file. If dirname is a relative path with elements like '.' or '..' then you are including them in the zip. Try something like fullname = os.path.join(root, f)[len(dirname):] to get relative paths in the zip - WinZip puts empty entries for directories in the zip. Maybe WinXP requires these. Kent -- http://mail.python.org/mailman/listinfo/python-list