Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Zipping and unzipping a single file

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #19969 |


    I am new to using Xceed and have spent most of the morning banging my head against a number of brick walls. I am trying to write some code that will allow me to zip/unzip a single file into/from an archive. I know that this should be very simple but I just can’t get it to work properly regardless of how I try and do it. So far I have tried the following to get the file C:\file.txt zipped into an archive called c:\archive.zip. Any help ar advice would be greatly appreciated!




    1) QuickZip


    QuickZip.Zip(@”C:\archive.zip”, @”C:\file.txt”);


    This appears to be blocked by the corporate anti-virus software as I think it
    is trying to write into a temporary folder and doesn’t have the correct


    System.UnauthorizedAccessException was unhandled
      Message=”Access to the path ‘C:\\Documents and Settings\\All Users\\Application Data\\Symantec\\SRTSP\\SrtETmp’ is denied.”
           at Xceed.FileSystem.AbstractFolder.CopyFilesTo(FileSystemEvents events, Object userData, AbstractFolder destinationFolder, Boolean recursive, Boolean replaceExistingFiles, Object[] filters)
           at Xceed.FileSystem.AbstractFolder.CopyFilesTo(AbstractFolder destinationFolder, Boolean recursive, Boolean replaceExistingFiles, Object[] filters)
           at Xceed.Zip.QuickZip.Zip(String zipFileName, String encryptionPassword, Boolean replaceExistingFiles, Boolean recursive, Boolean preservePaths, String[] filesToZip)
           at Xceed.Zip.QuickZip.Zip(String zipFileName, String[] filesToZip) …

    2)  From Martin Plante’s blog 

     Took code from here but no archive was created at all: http://blogs.xceedsoft.com/plantem/PermaLink.aspx?guid=7b3858fb-3d0f-43d8-8beb-7252943d68f1


    My code: 

    AbstractFile zipFile = new DiskFile(@”C:\archive.zip”);

    AbstractFile textFile = new ZippedFile(zipFile, @”C:\file.txt”);

     3) From another online example:

    ZipEvents ze = new ZipEvents();

    DiskFile sourceFile = new DiskFile(@”C:\archive.zip”);

    sourceFile.Create(ze, @”C:\file.txt”);


    – creates an archive but there’s nothing in it



    Imported from legacy forums. Posted by Ian (had 2071 views)

    Xceed Support
    Post count: 5658

    I’ll make this very simple:

    With the FileSystem:

    //To zip
    AbstractFile zipFile = new DiskFile( @”C:\Archive.zip” );
    ZipArchive archive = new ZipArchive( zipFile );

    AbstractFile textFile = new DiskFile( @”C:\Test.txt” );
    textFile.CopyTo( archive, true );

    //To unzip all the archive’s file
    AbstractFolder destinationFolder = new DiskFolder( @”C:\Destination” );
    archive.CopyFilesTo( destinationFolder, true, true, null );
    //To unzip the Test.txt file
    archive.CopyFilesTo( destinationFolder, true, true, “Test.txt” );


    Using QuickZip:

    QuickZip.Zip( @”C:\archive.zip”, @”C:\Test.txt” );
    //You can modify the temp folder using this line
    ZipArchive.DefaultTempFolder = @”C:\TempFolder”;
    QuickZip.Unzip( @”C:\archive.zip”, @”C:\Destination”, “*” );

    Imported from legacy forums. Posted by CharlesB (had 1986 views)

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