I cannot extract a password file using Dotnetzip

Asked

Viewed 84 times

-2

I am trying to extract a file called "1.zip" with a random password that I have put... but I’m making a mistake. "e was null".

At the point of burning the PC, I’m beginner in C#, I don’t know POO yet, at the beginning, I can’t solve this problem...

Follow the code link, I couldn’t format it.

https://pastebin.com/iESVMDBq

1 answer

1


Dude, I saw your code and I did a little implementation and it spun.

First I put the entire path of the read location concatenated with the zip file name.

Then I specified the file inside the . zip file that you want to pick up and save in another directory and it worked.

I put the variables apart to make it easier for you to read.

A tip what I give you is to never use accents or spaces to work with equal programming is in your namespace (namespace tentativa_de_extração_do_file) and in your directory to locate your file.

Follow the code below

    static void Main(string[] args)
    {
        string nomeDoArquivoZIP = "1.zip";
        string senhaDoArquivo = "w5KxT";

        var diretorioLerArquivo = @"C:\Stackoverflow\BRKappa";
        var diretorioSalvarArquivo = @"C:\Stackoverflow\BRKappa\output";
        var caminhoCompleto = diretorioLerArquivo + "\\" + nomeDoArquivoZIP;
        var nomeArquivoDentroArquivoZIP = "1.txt";


        using (ZipFile zip = ZipFile.Read(caminhoCompleto))
        {
            Directory.CreateDirectory(diretorioSalvarArquivo);
            foreach (ZipEntry e in zip)
            {
                if (e.FileName == nomeArquivoDentroArquivoZIP)
                    e.ExtractWithPassword(diretorioSalvarArquivo, ExtractExistingFileAction.OverwriteSilently, senhaDoArquivo);
            }
        }
    }
  • Really, it worked, thanks, a lot of people don’t even try to help... As a beginner, I was not able to solve at all (I spent the whole day trying). I can apply this to a loop using for, right? Because then, I have a sequence of files. " 1.zip" contains the "2.zip", "2.zip" contains the "3.zip"(so on). Until +ou- 300, I have the password of each of them, You can unpack one by one without having to unpack in hand, right? But anyway, thank you, the only thing I had to change was the "var fileName fileDentroArchvoZip = "2.zip".

  • Yes, you can do it. And if I got your problem right, it’s crazy, . zip inside . zip until you actually get into your real file. What you will have to do is create an index with your file number and the respective password for it, and in your for, when calling Extractwithpassword take this password by index and extract. The file name "1.txt" was just the example I put to test its code.

  • It’s really crazy, haha. It’s for a different project. And really, I thought about the index, but anyway, it was worth!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.