ExtractToDirectory,如何使用c#在zip文件夹中提取zip文件夹

Problem: I have this code that extracts all .zip folder inside a specified directory. Now my problem here is that my .zip files contains another .zip file inside of it. The output of my program is it creates a folder for the zip file extracted with a naming structure like this NUMBER_ + ZipFileName , now when I open the folder, it still contains a .zip folder inside. How do I extract a zip folder within a zip folder on the same NUMBER_ + ZipFileName Folder? It's kinda confusing to me.

这是我的剧本

public void extractZipFiles(string targetFileDirectory, string zipFileDirectory, string Number)
{
            Directory.GetFiles(zipFileDirectory, "*.zip", SearchOption.AllDirectories).ToList()
            .ForEach(zipFilePath => {
                var test = Number + "_" + Path.GetFileNameWithoutExtension(zipFilePath);
                var extractPathForCurrentZip = Path.Combine(targetFileDirectory, test);
                if(!Directory.Exists(extractPathForCurrentZip))
                {
                    Directory.CreateDirectory(extractPathForCurrentZip);
                }
                ZipFile.ExtractToDirectory(zipFilePath, extractPathForCurrentZip);
            });
}
评论