Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET extract single file from zip

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #19468 |

    Can someone tell me why the following code extracts all files from the zip?

    Dim files(1) As String
    files(0) = dir & “\descriptor.xml”
    Dim qz As QuickZip
    qz.Unzip(FileName, appPath & “tempzip\”, files)

    Shouldn’t it just extract descriptor.xml?

    Thanks,
    John

    Imported from legacy forums. Posted by JohnA229 (had 3760 views)

    User (Old forums)
    Member
    Post count: 23064

    In VB.NET, “Dim files(1) As String” creates a String aray with its lower bound being 0, and upper bound being 1. Thus a two strings array. You’re actually passing “dir & “\descriptor.xml”” and and empty string. An empty string reverts to unzipping everything from the root.

    Just change to “Dim files(0) As String”. I hate VB.NET for that array declaration convention!

    Imported from legacy forums. Posted by Martin (had 242 views)

    User (Old forums)
    Member
    Post count: 23064

    When unzipping the files how can I rename extracted files?

    Also is QuickZip is the only way to Unzip the files?

    Thanks

    – Chetan

    Imported from legacy forums. Posted by webchetan (had 310 views)

    User (Old forums)
    Member
    Post count: 23064

    You will need to use the FileSystem classes to do this. This is a way of unzipping files other than QuickZip.

    e.g. :

    AbstractFile archive = new DiskFile( @”D:\temp\temp.zip” );
    AbstractFile zippedFile = new ZippedFile( archive, “test.txt” );
    AbstractFile destination = new DiskFile( @”D:\temp\tempRenameFile.Txt” );
    zippedFile.CopyTo( destination, true );

    We have a sample explorer that shows how to do use the FileSystem classes.

    Go to Start Menu -> All Programs -> Xceed Components -> Our components in action! -> Xceed FileSystem Snippet Explorer.

    Then click on topic “3. Zip capabilities”. In the sub topics, you can look at the C# or VB.NET code, you can execute it, and you can even modify the code and execute it after!

    Imported from legacy forums. Posted by André (had 4365 views)

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