Click here to Skip to main content
15,434,147 members
Articles / Desktop Programming / Windows Forms
Posted 2 Dec 2009


78 bookmarked


Rate me:
Please Sign up or sign in to vote.
4.86/5 (27 votes)
2 Dec 2009CPOL5 min read
A comprehensive way to manage all of your downloaded zip files.

ZipTrack - Main Screen


Over the years, I've collected quite a few code and program examples. The problem is that sometimes I may remember I have an example of how to do something, but I can not find it. This program is designed to scan my downloaded zip files and parse the documents inside, then insert the content information into a database that can further be used to provide RegEx search on.

To that end, it provides me with a sort of Zip library. As such, I can add bookmarks concerning each zip file that take me back to the original article for the zip archive.

Version 1.0

Technologies and design approaches demonstrated

  • SQL Express 2008 Datasource
  • Custom framework Datalayer
  • Strongly typed Dataset
  • ICSharpCode.SharpZipLib
  • ICSharpCode.TextEditor
  • Creational / Factory / Proxy / Singleton - Design Patterns
  • Customized User Controls
  • Custom GUI designers
  • Owner drawn controls


Here is a step-by-step process for what you're going to need to do:

  1. Make sure you have SQL Server 2008 [^] installed on your machine.
  2. Ensure that you have the following DLL: ICSharpCode.SharpZipLib and ICSharpCode.TextEditor, from SharpDevelop [^] (included with the article download).
  3. Create the database on your own instance of SQL Server. The script can be found in the "...\Data\Create.dbArchive.sql" directory included with the solution.
  4. Change the ConnectionString property in the InitializeClass method of the Host class.
  5. Run the program. The sample website is included in the new database you created in the previous step.
  6. If you want to add one zip file at a time, click the "New archive" button.
  7. If you want to add several zip archives all at once, then click on the "Open" button located in the toolbar.
  8. Choose the website you want to associate with the file(s) that will be imported, and click the "Accept" button.
  9. Once this action is complete, click "Cancel" to close the form.
  10. By choosing the appropriate website from the [Website View], you should see the zip files that were found.
  11. You may choose to add one or more bookmarks after you have at least one zip file in [Zip File View].
  12. Once you select a Zip file on the left, its contents will be displayed in [Zip File Contents View] on the right.
  13. Select an ASCII text based file in [Zip File Contents View] and the file's contents will display in [File Content View].

ZipTrack - Main Screen


Let's begin by defining the domain specific language used by this utility program:

  1. Archive - An Archive represents a Zip file (e.g.,
  2. Bookmark - A Bookmark is an Internet shortcut stored in the database that links back to the original, or supporting web page article(s), and can be retrieved.
  3. Document - A Document is *any* content that is found inside a zip archive file (i.e., *.cs, *.txt, *.doc, *.dll, *.exe, *.vb, etc...).
  4. Website - Websites are used extensively by this program to associate each downloaded archive to an origination source.



Typically, the scenario is that most users will already have multiple files that have been previously downloaded on to the desktop PC. What we want to do is create a library of those files for easy lookup at a future date. Thus, the need for ZipTrack to organize and manage those files.


Often times, I am led to several places across the internet that offer various tips / tricks / solutions. I needed a way to categorize what I found and where. The best way that I have found to accomplish this was to put all files into separate directories named for the website I download from (e.g., CodeProject, etc...).

Website Categories


If you are like me, you have files that date back for more than just a couple of days, maybe even years. Using code found on the internet for listbox grouping, we can group our archives by date, much similar to the way that Microsoft Outlook groups email.

Archive Grouping


Probably the most beneficial part of this program is the ability to search within the zip archive(s) without having to unzip each file to examine its contents.

Archive Grouping

Datalayer architecture

The script file is included for you to re-create the database for your own SQL Server instance. The data layer consists of common inheritable objects that facilitate data retrieval and storage. The data layer consists of the following objects in no particular order:

  • Models - These objects provide a base class for any derived business class. The Business Object class inherits from the base class to share common functionality and properties.
  • Business Object - A business object that encapsulates all of the data and business behavior associated with the data table that it represents.
  • Manager Class - This Manager class is useful for easy access to the data store. All data is captured and supplied in this centralized repository. It serves as a creational design pattern to create and retrieve concrete business objects.
  • DataHandler - The DataHandler class provides a consistent interface to data available in many different sources and formats. It manages simple data requests, conversions, and related operations using DataRequestEventHandlers. It provides access to commands that can operate on the data.

Base model example

Namespace Common
    Public MustInherit Class Model

        Public MustOverride Property Name() As String

        Public MustOverride ReadOnly Property PrimaryID() As Integer

    End Class
End Namespace

Points of interest

One of the things that I found quite interesting during this project was when I needed a way to drag-n-drop shortcuts onto my form to help produce bookmarks. However, I needed a way to implement the GetData function for an Internet shortcut:


Private Sub BookmarksGrid1_DragDrop(ByVal sender As Object, _
            ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
    If e.Data.GetDataPresent("UniformResourceLocator", False) Then

        Dim data As Object = e.Data.GetData("UniformResourceLocator")

        Dim ms As MemoryStream = TryCast(data, MemoryStream)
        Dim bytes() As Byte = ms.ToArray()
        Dim encod As Encoding = Encoding.ASCII
        Dim LnkText As String = encod.GetString(bytes)


    ElseIf e.Data.GetDataPresent("FileNameW", False) Then

        'You can drag and drop items from the desktop or Explorer onto the DataGridView

        'Dim names As System.Array = _
        '     CType(e.Data.GetData("FileNameW", False), System.Array)
        'Dim LnkText As String = ResolveShellLink(CStr(names.GetValue(0)))


    End If
End Sub


During my search, I also ran across a way to retrieve link information for desktop shortcuts to files. You can now drag and drop items from the desktop or Explorer onto the DataGridView. Note that you'll get an array of file names since you can select multiple files and drop them; I just utilize the first item. To use this functionality, 'Add Reference' to c:\windows\system32\shell32.dll.

Private Function ResolveShellLink(ByVal name As String) As String
    ' --- Find the target for a short-cut
    If String.Compare(Path.GetExtension(name), ".lnk", True) <> 0 Then Return name
    Dim shl As New Shell32.Shell
    Dim dir As Shell32.Folder = shl.NameSpace(Path.GetDirectoryName(name))
    Dim itm As Shell32.FolderItem = dir.Items().Item(Path.GetFileName(name))
    Dim lnk As Shell32.ShellLinkObject = CType(itm.GetLink, Shell32.ShellLinkObject)
    Return lnk.Path
End Function


Although not implemented here, I think that I might implement the file shortcut method in the future. Also perhaps implement a way to add new websites to the database. Happy coding!!!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Founder Arkitech EBC Corporation
United States United States
MS, BBA, software developer, consultant, and trainer. Specializing in building data-centric applications designed for business, university, community & faith based organizations. Started developing Excel VBA macros and never looked back. Freelance developer utilizing VB.Net, SQL Server, Microsoft Access, and ASP.Net.

Comments and Discussions

GeneralMy vote of 5 Pin
Guirec18-Oct-12 23:37
professionalGuirec18-Oct-12 23:37 
GeneralMy vote of 5 Pin
Ranjan.D28-Sep-12 5:05
professionalRanjan.D28-Sep-12 5:05 
GeneralMy vote of 5 Pin
Polinia13-Jul-12 3:08
MemberPolinia13-Jul-12 3:08 
GeneralLooks really good - but a bit of a problem with date formats Pin
pt140115-May-10 8:37
Memberpt140115-May-10 8:37 
GeneralRe: Looks really good - but a bit of a problem with date formats Pin
pt140115-May-10 9:01
Memberpt140115-May-10 9:01 
GeneralUseful Application and Nice User Interface Pin
Irwan Hassan27-Jan-10 14:31
MemberIrwan Hassan27-Jan-10 14:31 
GeneralRe: Useful Application and Nice User Interface Pin
Terence Wallace27-Jan-10 17:33
MemberTerence Wallace27-Jan-10 17:33 
GeneralThis looks like it ROCKS! Pin
Ray Cassick21-Dec-09 5:08
MemberRay Cassick21-Dec-09 5:08 
GeneralRe: This looks like it ROCKS! Pin
Terence Wallace21-Dec-09 9:44
MemberTerence Wallace21-Dec-09 9:44 
Generalhe :) Pin
konikula20-Dec-09 12:36
Memberkonikula20-Dec-09 12:36 
GeneralA Good work Pin
infinitess7-Dec-09 16:05
Memberinfinitess7-Dec-09 16:05 
GeneralRe: A Good work Pin
Terence Wallace9-Dec-09 6:21
MemberTerence Wallace9-Dec-09 6:21 
GeneralVery interesting, got 5 from me Pin
Marcelo Ricardo de Oliveira7-Dec-09 11:03
mvaMarcelo Ricardo de Oliveira7-Dec-09 11:03 
GeneralRe: Very interesting, got 5 from me Pin
Terence Wallace7-Dec-09 11:08
MemberTerence Wallace7-Dec-09 11:08 
GeneralVery Good App [modified] Pin
rspercy655-Dec-09 4:58
Memberrspercy655-Dec-09 4:58 
GeneralRe: Very Good App Pin
Terence Wallace6-Dec-09 13:20
MemberTerence Wallace6-Dec-09 13:20 
GeneralRe: Very Good App Pin
rspercy656-Dec-09 13:31
Memberrspercy656-Dec-09 13:31 
GeneralRe: Very Good App Pin
Terence Wallace6-Dec-09 13:44
MemberTerence Wallace6-Dec-09 13:44 
GeneralRe: Very Good App Pin
Terence Wallace6-Dec-09 14:08
MemberTerence Wallace6-Dec-09 14:08 
GeneralRe: Very Good App Pin
rspercy656-Dec-09 15:09
Memberrspercy656-Dec-09 15:09 
GeneralRe: Very Good App Pin
Terence Wallace6-Dec-09 15:15
MemberTerence Wallace6-Dec-09 15:15 
GeneralRe: Very Good App Pin
rspercy6512-Dec-09 4:39
Memberrspercy6512-Dec-09 4:39 
GeneralNice - Thanks Pin
ChrisHar4-Dec-09 3:43
MemberChrisHar4-Dec-09 3:43 
GeneralRe: Nice - Thanks Pin
Terence Wallace6-Dec-09 13:14
MemberTerence Wallace6-Dec-09 13:14 
GeneralVery handy Pin
Dev_25803-Dec-09 20:24
MemberDev_25803-Dec-09 20:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.