How to Check File Exist or Not in WinRAR, 7Zip, Zip, Tar, Winzip in C#

621 views Asked by At

In my project I'm uploading a 7Zip, Zip, Tar, Winzip, WinRAR, and etc file.

Now I want to check if particular file is present in uploaded archive using C#.

Can anyone please help me?

1

There are 1 answers

2
Manish Puri On
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
    Boolean isFolderExist = false;

    foreach (ZipArchiveEntry entry in archive.Entries) {
        if (entry.FullName.Contains("PDFsDir/")) {                       
            isFolderExist = true;
        }
    }

    if (isFolderExist) {
        Console.WriteLine("the folder which name is pictures exists in zip file");
        if(entry.FileName.Contains( "PDFsDir" )==true) {
            Console.WriteLine("File Exist");
        }
    } else {
        Console.WriteLine("the folder doesn't exist ");
    }
}