Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5679 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Anyone got the recipe for extracting files from a zip-file (stored in a container field, though that's probably irrelevant since I can export it) to a specified location? I need it to work on Windows XP and Vista.

  • 3 weeks later...
Posted

Maybe, it will help...

On extracting files, it will not retain the subfolders tree.

It will also create a temporary folder to extract the files.

If you want other ideas: Java Examples

int unZipPhoto(String filePath, String tempPath, String tempFolderName){

	

	try{

		//Créer folder temp

		new File(tempPath + tempFolderName).mkdir();

	

		String pattern2="^.*/(.*..*)$";

		Pattern patternObj = Pattern.compile(pattern2);

		Matcher matcherObj;

		

		ZipFile zf = new ZipFile(filePath);

		Enumeration e = zf.entries();

		while (e.hasMoreElements()) {

			ZipEntry ze = (ZipEntry) e.nextElement();

		

			if (ze.getName().substring(1,2) != "_"){//Ne pas prendre les ressources

				if (ze.getName().matches(pattern2)){ //Vérifier présence d'un sous-dossier

		

					matcherObj = patternObj.matcher(ze.getName());

					matcherObj.find();   

					entryFilename = matcherObj.group(1);  

					

				}else{

					entryFilename=ze.getName();

				}

		

				FileOutputStream fout = new FileOutputStream(tempPath + tempFolderName + "/" + entryFilename);

				InputStream in1 = zf.getInputStream(ze);

				for (int c = in1.read(); c != -1; c = in1.read()) {

					fout.write©;

				}

				in1.close();

				fout.close();

			}

		}

	

		return 1;

	

	}catch (Exception e){

		return 0;

	}



}

  • 4 weeks later...
Posted

On extracting files, it will not retain the subfolders tree.

In my case, I absolutely need to preserve the full file and folder hierarchy. I've looked at various other solutions for unzipping files, and various failed for the same reason...

I can do this very nicely with PHP, so it looks like I'm going to have to get the SmartPill plug-in for this; not a big deal, but it really feels like overkill for what I'm trying to achieve (and I need this to work without an internet connection).

Posted

I'm pretty sure there is something to do to preserve the hierarchy in my script.

Also, have you looked the dacon's FileFire plugin?

http://www.dacons.net/fmplugins/filefireadvanced/

Posted

I'm certain it can be done in Java - I just don't have the time to do enough trial-and-error to get this working (my knowledge of java is very limited).

The Dacons plug-in does however look very promising - I actually hadn't heard of it. The Medium developer license isn't that expensive, considering the time I'd spend to get something else working. Will have to test it a bit more - my first attempt on a Mac worked fine except that I get an unwanted "_MACOSX" folder...

This topic is 5679 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.