Solved

Extract multiple .tar Files from a .Zip file

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Object Oriented Best Practice 5 35
Converting C# Objects into JSON file 7 41
Exception in Log4Net 1 20
C# Error - Add Failed 12 53
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now