[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Extract multiple .tar Files from a .Zip file

Posted on 2010-09-15
5
Medium Priority
?
685 Views
Last Modified: 2012-05-10
I have a zip file that I am downloading from an ftp site. Inside the zip file is a .tar file. Inside that tar file is another .tar file, and finally inside that last .tar file are 4 .txt files that are my target files. I am able to pull the files locally, but when it comes time to unzip them, using SharpZipLib, it doesn't recognize the .tar files inside the .zip. Any suggestions on how to get my 4 .txt files from inside the .zip?
0
Comment
Question by:Abacus IT
  • 4
5 Comments
 
LVL 1

Author Comment

by:Abacus IT
ID: 33682331
I've looked through that and some other links, and I found a part of SharpZipLib that should allow me to extract using a small piece of code that I will attach below. I am testing that code now to see what the outcome is.
using ICSharpCode.SharpZipLib.Tar;

        public static void Extract(string filename)
        {
            TarArchive ta = TarArchive.CreateInputTarArchive(new
            FileStream("C:/FTPFiles/Audit" + filename + ".tar", FileMode.Open, FileAccess.Read));
            ta.ExtractContents("C:/FTPFiles/Audit" + filename);
            ta.Close();
        }

Open in new window

0
 
LVL 1

Author Comment

by:Abacus IT
ID: 33682366
edit on the supplied code:

TarArchive ta = TarArchive.CreateInputTarArchive(new
            FileStream("C:/FTPFiles/Audit" + filename, FileMode.Open, FileAccess.Read));
0
 
LVL 1

Author Comment

by:Abacus IT
ID: 33682808
OK, I changed my code and will attach it. I am the problem is the sample code that I found that should be handling the extraction is giving me the following error:


Header checksum is invalid

How do I handle this?

public static void Extract(string filename)
        {
            TarArchive ta = TarArchive.CreateInputTarArchive(new FileStream(filename, FileMode.Open, FileAccess.Read));
            ta.ExtractContents("C:/FTPFiles/Audit/ ");
            ta.Close();
        }

Open in new window

0
 
LVL 1

Accepted Solution

by:
Abacus IT earned 0 total points
ID: 33683224
Solution has been found. I need to do a System extract on the original file, then call my SharpZipLib extract.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Screencast - Getting to Know the Pipeline
Suggested Courses

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question