×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

trouble extracting from zip file using SharpZipLib

trouble extracting from zip file using SharpZipLib

trouble extracting from zip file using SharpZipLib

(OP)
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; }

RE: trouble extracting from zip file using SharpZipLib

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?

RE: trouble extracting from zip file using SharpZipLib

(OP)
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).

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login


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