|
-
May 24th, 2012, 03:36 PM
#1
[RESOLVED] trouble extracting files using SharpZipLib
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;
}
-
May 24th, 2012, 03:56 PM
#2
Re: trouble extracting files using SharpZipLib
Maybe the files are stored with a path inside the Zip file.
-
May 24th, 2012, 04:56 PM
#3
Re: trouble extracting files using SharpZipLib
 Originally Posted by TomasRiker
Maybe the files are stored with a path inside the Zip file.
How can I prevent this?
Here's how I create the zip file:
Code:
ZipFile zipfile = ZipFile.Create(pathAndNameExtStripped + acmZipExtensionStr);
zipfile.BeginUpdate();
zipfile.Add(pathAndFileName);
zipfile.CommitUpdate();
zipfile.Close();
-
May 25th, 2012, 09:25 AM
#4
Re: trouble extracting files using SharpZipLib
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).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|