Welcome to the Xceed Community | Help
Community Search  
More Search Options

Extracting a tar.gz file problems

Sort Posts: Previous Next
  •  06-06-2012, 10:39 AM Post no. 32214

    Extracting a tar.gz file problems

    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.  
  •  06-08-2012, 4:32 PM Post no. 32220 in reply to 32214

    Re: Extracting a tar.gz file problems

    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.

     


    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!


    Diane Lafontaine
    Technical Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.