Steve
Steve

Reputation: 4553

how do we ensure that the extraction process is successful with C# ZipFile.ExtractToDirectory?

I have this C# code which unzip a zip file.

ZipFile.ExtractToDirectory(_downloadPath, _extractPath);

To test download process, I use the file size and compare them. But for extraction process, how do we ensure that the extraction process is successful? It could be corrupted (extraction process stop half way). Can I use file count to compare?

Upvotes: 0

Views: 347

Answers (1)

Hirasawa Yui
Hirasawa Yui

Reputation: 1296

I suggest you go ahead and compare md5 hash of files in archive and the ones that were extracted. Though it is definitely not the fastest process, this way you'll be 100% sure the data is not corrupted.

You can find how to get md5 of a file inside archive here: I have to take the directory of a file in zip file

Upvotes: 1

Related Questions