Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Extracting a tar.gz file problems

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #20475 |
    I have been trying to figure this out for a while now but cannot seem to figure it out. I keep getting a file system exception.
    The exception is:
    An unknown tar format was encountered.
    Type: Xceed.GZip.GZippedFile
    FullName: \SEARCH_JoeBlow_2010-11-09   
    My code:
    public override void ExtractTarGz(FileInfo searchFile, TransientFolder tempFolder)
                var gzipFile = new DiskFile(searchFile.FullName);
                if (!File.Exists(searchFile.FullName))
                AbstractFile tarFile = new GZippedFile(gzipFile);
                AbstractFolder archive = new TarArchive(tarFile);
                var destination = new DiskFolder(tempFolder.Folder.FullName);
                destination.CopyTo(archive, true);
    I am simply just trying to extract the gz file(searchfile) to the tempFolder. Any advice is much appreciated.  

    Imported from legacy forums. Posted by Aaron (had 1481 views)

    Diane [Xceed]
    Post count: 1353

    Hi Aaron,

    The following line in your code is incorrect:

       destination.CopyTo(archive, true);

    Since you want to extract from the archive, you want to copy items from the archive to the destination folder. As such you want to do this:

       archive.CopyFilesTo( destination, true, true );

    Here we use CopyFilesTo() on the source archive because CopyTo() wouldn’t work since ‘archive’ is a root folder and you can’t copy a root folder itself, only its contents, which CopyFilesTo() does.


    Imported from legacy forums. Posted by Diane [Xceed] (had 1089 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.