![]() |
Web Development »
Applications & Tools »
CodeProject Tools
Intermediate
License: The Code Project Open License (CPOL)
A tool to strip zips of unwanted files before submitting to CodeProjectBy Nishant SivakumarThe CPZipStripper tool with source code |
C++, C#, Windows, .NET1.1VS.NET2003, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

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.
Unzip the three files in release.zip to any permanent folder of your choice :-
Now just run CPZipStripper.exe once and exit. That's all.
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.


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.
private void MainForm_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
{
Array arr = (Array)e.Data.GetData(DataFormats.FileDrop);
if(arr != null)
{
//Doing it asynchronously else Explorer will freeze too
BeginInvoke(new DroppedFileHandler(FilterZip),
new object[] {arr.GetValue(0).ToString()});
}
}private void MainForm_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
{
//To change the mouse cursor if there are any files
e.Effect = e.Data.GetDataPresent(DataFormats.FileDrop) ?
DragDropEffects.Copy : DragDropEffects.None;
}
If you are interested in a generic function that will let you add a context menu item for a specific file type :-
See my blog entry : A simple C# function to add context menu items in Explorer and here's the function.
private bool AddContextMenuItem(string Extension,
string MenuName, string MenuDescription,
string MenuCommand)
{
bool ret = false;
RegistryKey rkey = Registry.ClassesRoot.OpenSubKey(
Extension);
if(rkey != null)
{
string extstring = rkey.GetValue("").ToString();
rkey.Close();
if( extstring != null )
{
if( extstring.Length > 0 )
{
rkey = Registry.ClassesRoot.OpenSubKey(extstring,true);
if(rkey != null)
{
string strkey = "shell\\" + MenuName + "\\command";
RegistryKey subky = rkey.CreateSubKey(strkey);
if(subky != null)
{
subky.SetValue("",MenuCommand);
subky.Close();
subky = rkey.OpenSubKey("shell\\" + MenuName, true);
if(subky != null)
{
subky.SetValue("",MenuDescription);
subky.Close();
}
ret = true;
}
rkey.Close();
}
}
}
}
return ret;
}
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.
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 :-
After all, prevention is better than cure, eh?
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 19 May 2004 Editor: Nishant Sivakumar |
Copyright 2004 by Nishant Sivakumar Everything else Copyright © CodeProject, 1999-2010 Web20 | Advertise on the Code Project |