Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This site is a great forum to exchange knowledge..."

Geography

Where in the world do Tek-Tips members come from?

trouble extracting from zip file using SharpZipLib

gib99 (Programmer)
24 May 12 16:41
Hello,

I'm using SharpZipLib and I'm trying to understand why my files are not extracting to the target directory that I specify.

I have a zip file under C:\tmp\TestData\. I want to extract it to C:\tmp\TestData\temp\. Instead, it extracts it to C:\tmp\TestData\temp\tmp\TestData\. That is, it seems to be taking the original path which the zip file is under and tacking that onto the target directory that I specify. Why is it doing this?

Here's my code:

CODE

private bool UnzipAcmZipFile(string pathAndName) { if (!File.Exists(pathAndName) || !pathAndName.EndsWith(acmZipExtensionStr)) { return false; } FastZip fastZip = new FastZip(); fastZip.ExtractZip(pathAndName, "C:\\tmp\\TestData\\temp\\", string.Empty); return true; }
DansDadUK (Programmer)
25 May 12 7:04
Perhaps because the ZIP file itself contains the compressed files/folders within a tmp folder.

What do you see if you just open the ZIP file within a ZIP-processing application? Does it show the files within the tmp (and perhaps subsidiary Testdata) folders?
gib99 (Programmer)
25 May 12 10:22
Here's how I was zipping the files:

CODE

ZipFile zipfile = ZipFile.Create(pathAndNameExtStripped + acmZipExtensionStr); zipfile.BeginUpdate(); zipfile.Add(pathAndFileName); zipfile.CommitUpdate(); zipfile.Close();

Here's how I'm zipping the files now:

CODE

ZipFile zipfile = ZipFile.Create(pathAndNameExtStripped + acmZipExtensionStr); zipfile.BeginUpdate(); zipfile.Add(pathAndFileName, fileNameWithoutPath); zipfile.CommitUpdate(); zipfile.Close();

This seems to work. By adding fileNameWithoutPath as the second argument to zipfile.Add(...) (the entryName), I'm actually able to name the entry (the file) which seems to determine how it gets unzipped (I'm assuming the default name included the full path).

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close