0

Hi I'm a newbie on C# and trying to Implement backup whole C and D as follow.

I have 2 questions

  1. I would like to add "excluded" folder statement into my code I would like to exclude folders "$Recycle.Bin" "windows" and file name "bootmgr" at the same time, how can I exclude these folders and a file into my code

  2. Although Ionic.zip has 256 AES encryption and password protection, It doesn't encrypt file names and file structure in zip file similar to winrar "Encrypt File Names" option. Is there any external exe file where I can call within c# code of each zip file and encrypt. How you do that to not show file structure ? do you use another zip tools or is there any paid or not library I can import C# to use.

Appreciate your answers

using Ionic.Zip;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



namespace compresszippasswordsplit
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var zipC = new ZipFile())
            {
                // Zip C
                int SizeBackupMB = 10000;
                string Password = "MysecurePassword";
                string ZipLocation = @"E:\Allbackups\C-backup" + DateTime.Now.ToString("-dd-MM-yyyy") + ".zip";
                string ZipDirectory = @"C:\";

                zipC.Password = Password;
                zipC.Encryption = EncryptionAlgorithm.WinZipAes256;
                zipC.AddDirectory(ZipDirectory);
                zipC.MaxOutputSegmentSize = 1024 * 1024 * SizeBackupMB;
                zipC.Save(ZipLocation);

            }
            using (var zipD = new ZipFile())
            {
                // Zip D
                int SizeBackupMB = 10000;
                string Password = "MysecurePassword";
                string ZipLocation = @"E:\Allbackups\D-backup" + DateTime.Now.ToString("-dd-MM-yyyy") + ".zip";
                string ZipDirectory = @"D:\";

                zipD.Password = Password;
                zipD.Encryption = EncryptionAlgorithm.WinZipAes256;
                zipD.AddDirectory(ZipDirectory);
                zipD.MaxOutputSegmentSize = 1024 * 1024 * SizeBackupMB;
                zipD.Save(ZipLocation);

            }
        }
    }
}
danone
  • 158
  • 9
  • 7zip can encrypt zip file meta data (file names) this post should get you going in the right direction https://stackoverflow.com/questions/3203701/sample-c-sharp-net-code-for-zipping-a-file-using-7zip – Steven Hoff Jul 09 '20 at 14:31
  • 7zip only support "encrypt file name" when you only create .7z extension not zip extension therefore it is not answer of my requirements. – danone Jul 09 '20 at 15:06

0 Answers0