A tool to strip zips of unwanted files before submitting to CodeProject

Fig. 1 - The red colored files will get stripped

Introduction

The CPZipStripper is a simple tool I've been using when editing and
submitting articles on CP, and all it does is to remove unwanted files from the
zips - like debug and obj folder files, suo files, pdb files, aps files etc. to
name a few. It's a one-click tool - so you don't have to waste time opening the
zip in WinZip or some such tool and then manually deleting unwanted files.

It would be very nice if article authors would use this tool on their zips
before sending it to us, so that the size of the mails received by the editors
will be considerably lesser.

Installation

Unzip the three files in release.zip to any permanent folder of your choice
:-

CPZipStripper.exe - This is the main executable (.NET IL exe targetted at FW
1.1)

CPZipStripperCfg.xml - Configuration file

ICSharpCode.SharpZipLib.dll - the DLL that I use for accessing the zip files
(SharpZipLib)

Now just run CPZipStripper.exe once and exit. That's all.

Using the tool

You can either drag/drop a zip into the program window or right click a zip
file and choose the "Open with ZipStrip" option, but for the context menu item
to get added, you'll need to run the program at least once - as it does not have
a separate installer.

Fig. 2 - Context menu item for zip files in Explorer

The buttons

Modify Config - This will open the config XML file in your windows
XML editor - if you don't have one, it will report an error. If so, manually
open the XML file in Notepad and make your changes.

The extensions node lists all extensions that need to be deleted

The paths node lists all paths that you want to be deleted (thus if you have
debug in there, any file whose extract path contains debug is deleted)

The files node lists any specific filenames that you want deleted

Refresh Listbox - If the zip file has changed or you have made
modifications to the XML config file, please hit the "Refresh Listbox" button

Strip Unwanted files - This will remove all the unwanted files (shown
in red in the listbox) and will replace the zip with a clean file, but also
backs up the old file.

Exit Program - Use this one with case, as it closes the program ;-)

Interesting points

Here are some odd things I learned :-)

Handling drag/drop was really easier than I expected it to be. First you need
to set the Form's AllowDrop property
to true. Then just handle the DragEnter and DragDrop events.

Conclusion

The UI is not much to look at, but the tool's worked for me. Let me know if
anyone has any suggestions/feedback through the article forum.

Post-Conclusion (dan g's tool)

While my tool is meant for stripping unwanted files from zip files,
dan g has an excellent article here on CP, describing a 3-in-1 tool that can
be used to package VC++ and .NET project files. I strongly urge people to take a
look at that one :-

License

Share

About the Author

Nish Nishant is a Principal Software Architect based out of Columbus, Ohio. He has over 17 years of software industry experience in various roles including Lead Software Architect, Principal Software Engineer, and Product Manager. Nish was a Microsoft Visual C++ MVP between 2002 and 2015.

Nish is an industry acknowledged expert in the Microsoft technology stack. He authored C++/CLI in Action for Manning Publications in 2005, and had previously co-authored Extending MFC Applications with the .NET Framework for Addison Wesley in 2003. In addition, he has over 140 published technology articles on CodeProject.com and another 250+ blog articles on his WordPress blog. Nish is vastly experienced in team management, mentoring teams, and directing all stages of software development.

Contact Nish : If you are interested in hiring Nish as a consultant, you can reach him via his google email id voidnish.

If I place ".bmp" in extension and I select 20 bmp files in explorer and execute the command, the explorer will open 20 instances of my program. How I do to these 20 bmp files will be, instead, 20 args of the command line???

you shouldn't mind it! People are... people, and actually they are free to post their votes the way they like.

The problem is ... another one. People going all over the pages should care and vote. A lot of our colleagues download the code (that's ok, that's why we are contributing it, but do not take a small fraction of a second to vote. Then the voting would really matter!

One note to adding context menu to Explorer: Your function seems to be "too shy", so it won't do anything in case the extension does not exist or there is no handling application.

In the first case it would be better to use CreateSubKey(), if the key exists, it will be opened (no harm). If it does not exist, then a new one will be created. You just check the default value and if there is none, you create a new value (I suggest with your application name). Then again you should call CreateSubKey() for the handling application key (either that existing or your new one, it does not matter) and proceed...

All that should be wrapped in try-catch, in many restricted environments SecurityException or UnauthorizedAccessException may be thrown.