I want to validate multipart compressed files like Zip because when any part missing for compressed files then it raises an error, but I want to validate it before extraction and different software creates a different naming structure.
I also refer one DotNetZip related questions.
The below screenshot is from 7z software.
And the second screenshot is from DotNetZip from C#.
One more thing is that I also want to test that it's also corrupted or not like 7z software. Please refer below screenshot for my requirements.
Please help me with these issues.
From your comments I understood that the issue you have is to identify the files (get the list of parts belonging together). You can get a list of files like
or for your second case
and then use the file list in your
CombinationStream
. The rest of the code would look like Manoj Choudhari wrote. You could also put the path and the file name with wild card into a parameter, so I'd suggest to add the following parameters to the function:and use it like:
or
To find out which kind of files you have in the basepath, you could write a helper function like
Modify it to your needs - it will return a list of strings containing "TAR", "ZIP" or "7ZIP" (or more than one of them), depending on the patterns matching against the files in the base directory.
Usage (example for multi-zipformat check):
Note: As per my experiments with this, it could happen that the files remain open although your program has ended - meaning your files will still be locked the next time you run your code. So, I'd strongly suggest to explicitly close them, like