Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Extract multiple .tar Files from a .Zip file

Posted on 2010-09-15
5
637 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 23

Expert Comment

by:Roshan Davis
ID: 33682262
0
 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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