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
    Posts
  • User (Old forums)
    Member
    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 22.23.09.001z.DITU-NOC.PKG.TAR   
     
     
    My code:
     
    public override void ExtractTarGz(FileInfo searchFile, TransientFolder tempFolder)
            {
                var gzipFile = new DiskFile(searchFile.FullName);
                if (!File.Exists(searchFile.FullName))
                    return;
                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]
    Moderator
    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.