Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Zipping empty folders

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

    I’m zipping and encrypting (AES) a folder with multiple folders and subfolders, a few of which are empty and using the QuickZip method. The empty folder disappear…any way to include them (other than the obvious trick of putting a dummy file in each)?

    Edmond

    Imported from legacy forums. Posted by ed (had 3938 views)

    Xceed Support
    Member
    Post count: 5658

    With the QuickZip method using wildcards, you can not include empty folders to the archive. However, it is really easy to do with our FileSystem instead.

    A folder listing containing:
    C:\TestFolder\NotEmptyFolder\
    C:\TestFolder\NotEmptyFolder\test.txt
    C:\TestFolder\EmptyFolder\

    e.g.,
    AbstractFolder folder = new DiskFolder( @”C:\TestFolder” );
    AbstractFile zipFile = new DiskFile(@”C:\ZipArchive.zip” );

    AbstractFolder zipArc = new ZipArchive( zipFile );
    folder.CopyTo( zipArc, true );

    After, the ZipArchive.zip will contain:
    TestFolder\NotEmptyFolder\
    TestFolder\NotEmptyFolder\test.txt
    TestFolder\EmptyFolder\

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

    User (Old forums)
    Member
    Post count: 23064

    Yes…I’ve seen that technique used in other posts. But like I said…I’m encrypting it with AES. Is there a way to ensure the resultant archive file is encrypted?

    Merci!

    Edmond

    Imported from legacy forums. Posted by ed (had 342 views)

    Xceed Support
    Member
    Post count: 5658

    Sorry, I missed the AES part of the question.

    e.g.,
    AbstractFile zipFile = new DiskFile( @”D:\Dump\ZipTry.zip” );
    AbstractFile textFile = new DiskFile( @”D:\Dump\Test.txt” );
    ZipArchive zipArc = new ZipArchive( zipFile );
    zipArc.DefaultEncryptionMethod = EncryptionMethod.WinZipAes;
    zipArc.DefaultEncryptionPassword = “Sun”;
    AbstractFile zippedFile = new ZippedFile( zipFile, @”subfolder\Test.txt” );
    textFile.CopyTo( zippedFile, true );

    The “Test.txt” file will be encrypted and nested inside the “subfolder”.

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

    User (Old forums)
    Member
    Post count: 23064

    Merci!

    That’s just what I was looking for…

    Edmond

    Imported from legacy forums. Posted by ed (had 4930 views)

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