Unzip folder keeping folder structure

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 1766 Views - Last Post: 27 December 2012 - 08:13 PM Rate Topic: -----

#1 AVividLight  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-December 12

Unzip folder keeping folder structure

Posted 26 December 2012 - 11:28 AM

Hey guys,

I'm trying to unzip an application, but every method I've tried either doesn't keep the folder structure, or doesn't unzip all the files.
I've tried using SharpZipLib.dll, Ionic.dll, zipUnzip.dll, and one other, but I forgot it's name.

I should point out that SharpZipLib didn't have any of the issues I mentioned above; instead it put my project directory in front of the input and output directories. I don't understand why...

Anyway, I'm hoping somebody can suggest another library to try, or give me some tips on using one of the libraries I mentioned above.

Thanks for your time! - Gibson

Is This A Good Question/Topic? 0
  • +

Replies To: Unzip folder keeping folder structure

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5675
  • View blog
  • Posts: 12,192
  • Joined: 02-June 10

Re: Unzip folder keeping folder structure

Posted 26 December 2012 - 11:47 AM

Unzip an application? Like Unzip an executable? That doesn't make sense.

nor does putting a directory "in front of" something else.

I can't make heads or tails out of what is really happening on your system. Do you have a screen shot so we can all see what you see?
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: Unzip folder keeping folder structure

Posted 26 December 2012 - 02:06 PM

If you show us your code, we maybe better able to help you. Chances are that you are just not examining the other properties of the ZipEntry to check for relative paths, and using that information to create the output files.

Part of responsibility one takes on when using an open source library is learning how to use it properly. That involves reading the documentation that comes with it, and if poorly documented, digging into the source code itself.
Was This Post Helpful? 1
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: Unzip folder keeping folder structure

Posted 26 December 2012 - 02:19 PM

Taking a quick peek at DotNetZip's .CHM file, it looks like if you call ZipFile.ExtractAll() (The one that comes from Ionic) passing in the directory to extract to, the appropriate tree structure will be unzipped using the directory that you passed in as the root.
Was This Post Helpful? 0
  • +
  • -

#5 AVividLight  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-December 12

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 02:45 PM

Hey guys, thanks for the quick response, and sorry it's taken me so long to reply.

View PosttlhIn`toq, on 26 December 2012 - 11:47 AM, said:

Unzip an application? Like Unzip an executable? That doesn't make sense.

nor does putting a directory "in front of" something else.

I can't make heads or tails out of what is really happening on your system. Do you have a screen shot so we can all see what you see?


By "unzip an application", I mean an application file. I say that specifically because on Mac all the data for an application is stored with the executable in a directory. That directory is given the extension ".app", and closed (if you open the directory, you open the app instead).

Posted Image

By "putting a directory in front of something else", I mean I can give it the directory "/Users/Gibson/Desktop", and it will put "/Users/GibsonBethke/Documents/Projects/Unity/Current/UnityMusicPlayer/Automatic Updater" in front of that, resulting in "/Users/GibsonBethke/Documents/Projects/Unity/Current/UnityMusicPlayer/Automatic Updater\Users\GibsonBethke\Desktop\UnityMusicPlayer.app\". Also, I just noticed that it's changing the path separator character.

Posted Image

Thanks for your input!

View PostSkydiver, on 26 December 2012 - 02:06 PM, said:

If you show us your code, we maybe better able to help you. Chances are that you are just not examining the other properties of the ZipEntry to check for relative paths, and using that information to create the output files.

Part of responsibility one takes on when using an open source library is learning how to use it properly. That involves reading the documentation that comes with it, and if poorly documented, digging into the source code itself.


I'm using the example that the developer provided.

void Start ()
	{

		using (ZipFile zipfile = ZipFile.Read("/Users/GibsonBethke/Desktop/UnityMusicPlayer.zip"))
		{

			foreach (ZipEntry entry in zipfile)
			{

				entry.Extract("/Users/GibsonBethke/Desktop", ExtractExistingFileAction.OverwriteSilently);
			}
		}
	}


View PostSkydiver, on 26 December 2012 - 02:19 PM, said:

Taking a quick peek at DotNetZip's .CHM file, it looks like if you call ZipFile.ExtractAll() (The one that comes from Ionic) passing in the directory to extract to, the appropriate tree structure will be unzipped using the directory that you passed in as the root.


I haven't been able to find ZipFile.ExtractAll, could you provide a little more information on that?

Thanks for all your willingness to help, guys! I hope I've cleared some of the confusion up; if not, please let me know!
Was This Post Helpful? 0
  • +
  • -

#6 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5675
  • View blog
  • Posts: 12,192
  • Joined: 02-June 10

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 02:58 PM

In the future you might want to specify stuff like "this is a macintosh .app archive" especially when you are posting to a C# help forum where everyone is going to naturally presume you're talking about Windoze files.
Was This Post Helpful? 0
  • +
  • -

#7 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5675
  • View blog
  • Posts: 12,192
  • Joined: 02-June 10

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 03:06 PM

If this is C# but on a Mac then you're using Mono to give you the C# framework - is that right? You might be getting some odd behavior from that.

I'd try making all this work on Windows first. Learn the oddities of the library you're using under known-working conditions. *THEN* port it to Mac under Mono.
Was This Post Helpful? 0
  • +
  • -

#8 AVividLight  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-December 12

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 03:56 PM

View PosttlhIn`toq, on 27 December 2012 - 02:58 PM, said:

In the future you might want to specify stuff like "this is a macintosh .app archive" especially when you are posting to a C# help forum where everyone is going to naturally presume you're talking about Windoze files.


Yeah, that's a good idea, thanks for the tip!

View PosttlhIn`toq, on 27 December 2012 - 03:06 PM, said:

If this is C# but on a Mac then you're using Mono to give you the C# framework - is that right? You might be getting some odd behavior from that.

I'd try making all this work on Windows first. Learn the oddities of the library you're using under known-working conditions. *THEN* port it to Mac under Mono.


Well, I don't have a windows to use, so using Mono on Mac is the best I can do.
I've been using Mono for over two years, and I haven't had any issues; I don't really think that Mono is causing it, although I guess I can't be sure.

Anyway, thanks.
Was This Post Helpful? 0
  • +
  • -

#9 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 05:41 PM

View PostAVividLight, on 27 December 2012 - 04:45 PM, said:

View PostSkydiver, on 26 December 2012 - 02:19 PM, said:

Taking a quick peek at DotNetZip's .CHM file, it looks like if you call ZipFile.ExtractAll() (The one that comes from Ionic) passing in the directory to extract to, the appropriate tree structure will be unzipped using the directory that you passed in as the root.


I haven't been able to find ZipFile.ExtractAll, could you provide a little more information on that?

Thanks for all your willingness to help, guys! I hope I've cleared some of the confusion up; if not, please let me know!


Try this link: http://dotnetzip.her...b5e01afe602.htm
It it is referenced from: http://dotnetzip.cod...m/documentation
Was This Post Helpful? 1
  • +
  • -

#10 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5675
  • View blog
  • Posts: 12,192
  • Joined: 02-June 10

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 06:04 PM

View PostAVividLight, on 27 December 2012 - 04:56 PM, said:

Well, I don't have a windows to use, so using Mono on Mac is the best I can do.
I've been using Mono for over two years, and I haven't had any issues; I don't really think that Mono is causing it, although I guess I can't be sure.


Had you considered installing Windows on the Mac?
http://support.apple.com/kb/HT1461

You can then boot to either OS. Plus you can then use Visual Studio to do your development in. I'm not even sure *how* you are developing for C# without using the IDE that was built for it. What program on the Mac are you using to build this C#/mono application?
Was This Post Helpful? 0
  • +
  • -

#11 AVividLight  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-December 12

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 06:30 PM

View PosttlhIn`toq, on 27 December 2012 - 06:04 PM, said:

What program on the Mac are you using to build this C#/mono application?


I'm using the Unity3d engine.

View PostSkydiver, on 27 December 2012 - 05:41 PM, said:



The page doesn't load due to the server not responding. Does it work for you? If it does, can you copy/paste the main text you want me to see?
Was This Post Helpful? 0
  • +
  • -

#12 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 06:36 PM

Both links work for me. I can't paste in just the main text since the point is for you to learn how to read documentation.

Go to dotnetzip.codeplex.com. Click on the Documentation tab. Click on the "Reference Doc" link. Dig down to Reference>Ionic.Zip namespace>ZipFile class>ExtractAll() method>ExtractAll Method(path)
Was This Post Helpful? 0
  • +
  • -

#13 AVividLight  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-December 12

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 06:45 PM

View PostSkydiver, on 27 December 2012 - 06:36 PM, said:

Both links work for me. I can't paste in just the main text since the point is for you to learn how to read documentation.

Go to dotnetzip.codeplex.com. Click on the Documentation tab. Click on the "Reference Doc" link. Dig down to Reference>Ionic.Zip namespace>ZipFile class>ExtractAll() method>ExtractAll Method(path)


I've tried that a number of times, and the page always returns with a "server not responding" error. I could try to go through a proxy, but I can assure you I do know how to read documentation.

Anyway, thanks for help so far!

I should add that I've tried accessing the documentation for DotNetZip all week, and haven't had any other results.
Was This Post Helpful? 0
  • +
  • -

#14 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3662
  • View blog
  • Posts: 11,466
  • Joined: 05-May 12

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 06:50 PM

If you downloaded DotNetZip, the same documentation is also in the .CHM file.

Anyway, all the documentation indicates is that you pass in the target path where to expand to. If it doesn't expand properly, then it's a bug in the library. But since it's open source you should be able to trace through the code, find the problem, and hopefully submit a patch to fix it.
Was This Post Helpful? 0
  • +
  • -

#15 AVividLight  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 26-December 12

Re: Unzip folder keeping folder structure

Posted 27 December 2012 - 07:34 PM

Alright, I'll look through that, thanks again!

By the way, what application would open a .chm file?

Well, never mind; I've downloaded an application for this purpose.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2