tobiasschulz / tar-cs

Automatically exported from code.google.com/p/tar-cs
Other
0 stars 0 forks source link

Cannot open file .... as archive #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am using the sample code given on the documentation page

 private void Abc()
        {
            using (var outFile = File.Create("myOutFile.tar.gz"))
            {
                using (var outStream = new System.IO.Compression.GZipStream(outFile, System.IO.Compression.CompressionMode.Compress ))
                {
                    using (var writer = new TarWriter(outStream))
                    {
                        writer.ReadOnZero = true;
                        writer.Write("test22.txt");
                    }
                }
            }
        }

It generates the tar and gzip file without reporting any errors, but when I use 
7-Zip to open the gzip, it gives me the .tar file. but when i try to open the 
tar file using 7Zip, it gives me an error "Cannot open file 
c:\....\myOutFile.tar as archive.

Any help would be appreciated.

Original issue reported on code.google.com by vnancha...@gmail.com on 12 Jan 2011 at 2:29

GoogleCodeExporter commented 9 years ago
I am also experiencing this issue. Is there something wrong with the tar format?

Original comment by aparker....@gmail.com on 19 May 2011 at 7:27

GoogleCodeExporter commented 9 years ago
make sure that streams are closed properly and tar and gzip are not the stream 
owners. If you are using something like this:

using (MemoryStream ms = new MemoryStream())
 using (GZipOutputStream gzipStream = new GZipOutputStream(ms))
  using (TarOutputStream tarOutputStream = new TarOutputStream(gzipStream))
            {
             .....
                        TarEntry entry = TarEntry.CreateTarEntry(tarName);
                        entry.Size = fileSize;
                        tarOutputStream.PutNextEntry(entry);
                         .....
                        tarOutputStream.CloseEntry();

                tarOutputStream.IsStreamOwner = false;
                tarOutputStream.Close();

                gzipStream.IsStreamOwner = false;
                gzipStream.Close();

                ms.Flush();

            }

Original comment by vnancha...@gmail.com on 19 May 2011 at 11:39

GoogleCodeExporter commented 9 years ago

Original comment by vasilt...@gmail.com on 17 Jun 2011 at 8:31