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: 1071
Registered: March 2006
Location: Italy
Experienced 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: 1071
Registered: March 2006
Location: Italy
Experienced 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: 12096
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: Tue Nov 12 22:05:15 CET 2019

Total time taken to generate the page: 0.02128 seconds