Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Zip all files in a directory
Zip all files in a directory [message #43054] Sun, 27 April 2014 21:38 Go to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
Hello,

I would like to zip all files in a given directory and save the archived .zip. Unfortunately the reference case does not help me Embarassed . This is my experiment
	FileZip zip(TD.PATHDIRWWW+"compress.zip");
        String targetdir = TD.PATHDIRWWW;
	FindFile fff(AppendFileName(targetdir, "*.*"));
	while(fff) {
			if(fff.IsFile()) {
				zip.WriteFile(LoadFile(fff.GetName()), fff.GetName());
			}
			fff.Next();
	}
	zip.Finish();

But produces a zipped archive with empty files. Of course I am using the wrong zip method. Which the correct one?
Thanks,
Luigi
Re: Zip all files in a directory [message #43062 is a reply to message #43054] Mon, 28 April 2014 20:29 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1182
Registered: March 2006
Location: Italy
Senior Contributor
I found the mistake Cool

The correct line was

zip.WriteFile(LoadFile(TD.PATHDIRWWW+fff.GetName()), fff.GetName());

without the path it was impossible to load the right file.
Luigi
Re: Zip all files in a directory [message #43071 is a reply to message #43062] Fri, 02 May 2014 07:47 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
...or, BTW, you can also use fff.GetPath() there....

Mirek
Previous Topic: [BUG] GLDraw on multiple window on the same time doesn't work
Next Topic: Problem displaying using TURTLE
Goto Forum:
  


Current Time: Fri Mar 29 15:12:27 CET 2024

Total time taken to generate the page: 0.01650 seconds