sharpziplib unzip tar sample framework 2.0

J

julio

Hi,
I write a program to unzip a Tar file generated on a Unix environment file
using SharpZipLib, but returns a error "Header checksum is invalid" when
execute the program.
This error appears when I try to extract the files.
Can any help me where is a sample to unzip a tar file
TIA
Julio
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

I have always use SharpZipLib and I haven't find a problem yet.Are you sure
the problem is unzipping it?
How you get the file from the Unix system?
Can you unzip it in windows?
 
J

julio

Ignacio,
This program that I developed is to replace one thats exits from 1992
Each day the unix system zips the data into a tar file and the actual
program under VB 6 using the unrar file unzip this file into 60 diferent
files.
This program works fine, but we need to replace with one thats works using
the .Net Framework 2.0, like all others proccess that are redisegned during
2007.
TIA
Julio
 
A

Arne Vajhøj

julio said:
I write a program to unzip a Tar file generated on a Unix environment file
using SharpZipLib, but returns a error "Header checksum is invalid" when
execute the program.
This error appears when I try to extract the files.
Can any help me where is a sample to unzip a tar file

Some quick code is attached below.

Arne

=================================================

using System;
using System.IO;
using ICSharpCode.SharpZipLib.Tar;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
List();
Extract();
Console.ReadKey();
}
public static void List()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new
FileStream(@"C:\vir.tar", FileMode.Open, FileAccess.Read));
ta.ProgressMessageEvent += MyLister;
ta.ListContents();
ta.Close();
}
public static void Extract()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new
FileStream(@"C:\vir.tar", FileMode.Open, FileAccess.Read));
ta.ProgressMessageEvent += MyNotifier;
ta.ExtractContents(@"C:\vir");
ta.Close();
}
public static void MyLister(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " " + te.Size + " " + te.ModTime);
}
public static void MyNotifier(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " extracted");
}
}
}
 
J

julio

Arne,
I have the same trouble, the error message that display is:
An unhandled exception of type 'ICSharpCode.SharpZipLib.Tar.TarException'
occurred in ICSharpCode.SharpZipLib.dll
Additional information: Header checksum is invalid
I dont know what is the reason for this problem, maybe need to to setup some
params?
TIA
Julio

Arne Vajhøj said:
julio said:
I write a program to unzip a Tar file generated on a Unix environment file
using SharpZipLib, but returns a error "Header checksum is invalid" when
execute the program.
This error appears when I try to extract the files.
Can any help me where is a sample to unzip a tar file

Some quick code is attached below.

Arne

=================================================

using System;
using System.IO;
using ICSharpCode.SharpZipLib.Tar;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
List();
Extract();
Console.ReadKey();
}
public static void List()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new
FileStream(@"C:\vir.tar", FileMode.Open, FileAccess.Read));
ta.ProgressMessageEvent += MyLister;
ta.ListContents();
ta.Close();
}
public static void Extract()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new
FileStream(@"C:\vir.tar", FileMode.Open, FileAccess.Read));
ta.ProgressMessageEvent += MyNotifier;
ta.ExtractContents(@"C:\vir");
ta.Close();
}
public static void MyLister(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " " + te.Size + " " + te.ModTime);
}
public static void MyNotifier(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " extracted");
}
}
}
 
F

Family Tree Mike

Ignacio made a good suggestion that I don't believe you responded. Compare
the tar file that was downloaded by your new code to the file that is
downloaded by the old code. They should be identical. Further, winzip
outside of your application will be able to open both.

Potentially there is a problem in the code you moved from VB 6 to .Net for
doing the download. This test will confirm or eliminate this possibility.
 
J

julio

Maybe can be that you dont understand that I say or maybe I answer with an
idea that you dont receipt, but if I work using winrar, I can unTar the file,
and work as desired.
But when I execute the program, appears the abovementioned error
Perhaps the problem is related to any undeclared setting, ot an undeclared
value in .config file, but I dont know what the problem is
If you can send me any idea or suggestion, I will test this suggenstion
TIA
 
A

Arne Vajhøj

julio said:
Using winrar works fine, and the file is unTarged

Hmm.

Are the file by any chance *BOTH* tarred and gzipped ?

If so then you need to gunzip before untarring.

Example below.

Arne

============================================

using System;
using System.IO;
using System.IO.Compression;
using ICSharpCode.SharpZipLib.Tar;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
List();
Extract();
Console.ReadKey();
}
public static void List()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new GZipStream(new
FileStream(@"C:\vir.tar.gz", FileMode.Open, FileAccess.Read),
CompressionMode.Decompress));
ta.ProgressMessageEvent += MyLister;
ta.ListContents();
ta.Close();
}
public static void Extract()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new GZipStream(new
FileStream(@"C:\vir.tar.gz", FileMode.Open, FileAccess.Read),
CompressionMode.Decompress));
ta.ProgressMessageEvent += MyNotifier;
ta.ExtractContents(@"C:\vir");
ta.Close();
}
public static void MyLister(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " " + te.Size + " " + te.ModTime);
}
public static void MyNotifier(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " extracted");
}
}
}
 
J

julio

Arne,
Amaizing, with this simple line, now works fine, and unTar the file
Thank you very much for your help
Julio

Arne Vajhøj said:
julio said:
Using winrar works fine, and the file is unTarged

Hmm.

Are the file by any chance *BOTH* tarred and gzipped ?

If so then you need to gunzip before untarring.

Example below.

Arne

============================================

using System;
using System.IO;
using System.IO.Compression;
using ICSharpCode.SharpZipLib.Tar;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
List();
Extract();
Console.ReadKey();
}
public static void List()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new GZipStream(new
FileStream(@"C:\vir.tar.gz", FileMode.Open, FileAccess.Read),
CompressionMode.Decompress));
ta.ProgressMessageEvent += MyLister;
ta.ListContents();
ta.Close();
}
public static void Extract()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new GZipStream(new
FileStream(@"C:\vir.tar.gz", FileMode.Open, FileAccess.Read),
CompressionMode.Decompress));
ta.ProgressMessageEvent += MyNotifier;
ta.ExtractContents(@"C:\vir");
ta.Close();
}
public static void MyLister(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " " + te.Size + " " + te.ModTime);
}
public static void MyNotifier(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " extracted");
}
}
}
 
S

sundarrajan chithambaram

by using ur project i can able to extract tar.gz file but how to extract the tar,tar.Z file kinldy help me to resolve this problem


thanks
sundar
Hi,
I write a program to unzip a Tar file generated on a Unix environment file
using SharpZipLib, but returns a error "Header checksum is invalid" when
execute the program.
This error appears when I try to extract the files.
Can any help me where is a sample to unzip a tar file
TIA
Julio
On Monday, February 04, 2008 2:32 PM Ignacio Machin \( .NET/ C# MVP \) wrote:
Hi,

I have always use SharpZipLib and I haven't find a problem yet.Are you sure
the problem is unzipping it?
How you get the file from the Unix system?
Can you unzip it in windows?

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
news:[email protected]...
Some quick code is attached below.

Arne

=================================================

using System;
using System.IO;
using ICSharpCode.SharpZipLib.Tar;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
List();
Extract();
Console.ReadKey();
}
public static void List()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new
FileStream(@"C:\vir.tar", FileMode.Open, FileAccess.Read));
ta.ProgressMessageEvent += MyLister;
ta.ListContents();
ta.Close();
}
public static void Extract()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new
FileStream(@"C:\vir.tar", FileMode.Open, FileAccess.Read));
ta.ProgressMessageEvent += MyNotifier;
ta.ExtractContents(@"C:\vir");
ta.Close();
}
public static void MyLister(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " " + te.Size + " " + te.ModTime);
}
public static void MyNotifier(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " extracted");
}
}
}
Hmm.

Are the file by any chance *BOTH* tarred and gzipped ?

If so then you need to gunzip before untarring.

Example below.

Arne

============================================

using System;
using System.IO;
using System.IO.Compression;
using ICSharpCode.SharpZipLib.Tar;

namespace E
{
public class Program
{
public static void Main(string[] args)
{
List();
Extract();
Console.ReadKey();
}
public static void List()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new GZipStream(new
FileStream(@"C:\vir.tar.gz", FileMode.Open, FileAccess.Read),
CompressionMode.Decompress));
ta.ProgressMessageEvent += MyLister;
ta.ListContents();
ta.Close();
}
public static void Extract()
{
TarArchive ta = TarArchive.CreateInputTarArchive(new GZipStream(new
FileStream(@"C:\vir.tar.gz", FileMode.Open, FileAccess.Read),
CompressionMode.Decompress));
ta.ProgressMessageEvent += MyNotifier;
ta.ExtractContents(@"C:\vir");
ta.Close();
}
public static void MyLister(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " " + te.Size + " " + te.ModTime);
}
public static void MyNotifier(TarArchive ta, TarEntry te, string msg)
{
Console.WriteLine(te.Name + " extracted");
}
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top