How to Compress a file or a fold in to zip file with/without password On Net

Hi, Support:
Would you help me how to compress a file into a zip file or a fold including subfold and subfold-files into a zip file or many files into a zip file, with/without password On VB.Net?

Thanks.

Method CreateEntries adds to an archive all content with subfolders and their files recursively.
You can add entries with such names that they constitute a folders/subfolders within an archive regardless of file origins:

archive.CreateEntry(@"root\subfolder\fable.txt", @"D:\Text\fable.txt");
archive.CreateEntry(@"root\subfolder\song.mp3", @"D:\Music\Radio\Alice_singing.mp3");

Ok!
That’s fine.
And how about to create Zip archrvie with password protected? I can not work it out. Please help me .

Hello, here is an article for you - Password Protecting Archives.
I advise you to encrypt zip archives with AES technique and avoid traditional encryption.

Thanks for your instruction.
However, the sub-link is nothing in the "Password Protecting Archives " page, would you please provide me a whole demo how to encrypt file or fold with password?
Thanks.

Below is a sample of encryption with AES256 in C#.

using (FileStream zipFile = File.Open("PasswordProtectWithAES256_out.zip", FileMode.Create))
{                
     using (var archive = new Archive(
         new ArchiveEntrySettings(null, new AesEcryptionSettings("T0p$ecret", EncryptionMethod.AES256))))
     {
         archive.CreateEntry(...);
         ...
         archive.Save(zipFile);
      }                
}

Thanks!
However, the demo codes are not suitable for VB.net. And I try to rewrite as Net one, but fail. Would you please provide me a demo for Net?

Here is a VB sample.
vb.zip (3.7 KB)

That’s OK!
Thank you very much!
And another question is that:
How to show the packing/unpacking progress information as percent for a big file i.e. more than 100M or even 1G?
and for a big file(i.e. >100M),how to show the left packing/unpacking time?
The above two information is useful for users, because the will know d the progress and left time when doing!

There are compression progress and extraction progress events.
The following C# sample demonstrates how to report compression progress to console:

using (FileStream source = File.Open("huge.bin", FileMode.Open, FileAccess.Read))
{
    using (var archive = new Archive())
    {
        ArchiveEntry entry = archive.CreateEntry("huge.bin", source);
        int percentReady = 0;
        entry.CompressionProgressed += (s, e) =>
             {
                 int percent = (int)((100 * (long)e.ProceededBytes) / source.Length);
                 if (percent > percentReady)                 
                 {
                     Console.WriteLine(string.Format("{0}% compressed", percent));
                     percentReady = percent;
                 }       
             };
        archive.Save(zipFile);
    }
}

Hope you can convert to to VB.

There is no prediction of expected time. If you need it, you can estimate compression/extraction velocity having elapsed time, and make an preditopn of the rest time.