Hey everyone! I'm building a VB .Net WinForms app to archive project directories at work by copying files older than a year to a storage RAID. It works great, including a binary comparison of the source and copied files to ensure everything went smoothly before deleting the originals.
Next, I want to compress these archived directories into individual zip files using the built-in function in .NET: `System.IO.Compression.ZipFile.CreateFromDirectory(...)`. My questions are:
1. What's the best way to verify that the zipped files are accurate before I go ahead and delete the source files? I don't want to risk any file corruptions.
2. Are there other compression methods I should consider aside from zip? I did test out 7zip, but I'd like to keep everything integrated in one app unless there's a compelling reason not to.
Thanks!
5 Answers
You can decompress the zip file and use a tool like `diff` to compare the original files with the decompressed ones. If you're dealing with directories, just remember to use the `-r` flag for a recursive comparison! Alternatively, you could generate SHA256 checksums for the files before zipping and compare those checksums after unzipping to ensure everything matches.
You might also want to look into using a compressed file system, as it does some of what you're trying to accomplish. However, for portability and compatibility, sticking with zip files might be the better option. They’ve stood the test of time and include CRC checks, giving you some peace of mind about data integrity.
I've found that using zlib is a solid choice. It has built-in checksums that ensure data integrity when uncompressing. You’ll need to decompress the files to check if zlib reports any errors; if it doesn’t, you can be pretty sure the zipping process was successful.
There's a more reliable method involving checksums or hash values. Using these can help you verify file integrity before deleting anything. After zipping, generate a checksum for your files and then again after decompressing. If they match, you’re all good!
For verification, just unzip the file and do a diff of the contents. It's simple and effective! If anything doesn’t match up, you'll know immediately.
Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically