Saturday, August 18, 2007

As PlateWire's popularity continues to grow, I have noticed more web sites of a similar nature launching on a regular basis. After some discussion with other webmasters (including AboveAverageDriver.com's Chris) I came to the conclusion that this niche market would benefit from having one single clearing house to exchange messaging of license plates.

For instance, say Joe in California, witnesses Suzy's teenage daughter driving recklessly down the highway. Perhaps Joe does contact the authorities but they deem it low priority. So Joe goes home and send a "wire" to the plate, using AboveAverageDriver. Suzy on the other hand is registered on PlateWire to receive a notification if any of her plates are messaged. WIthout PlateXchange, Judy would have not received the message regarding her daughters reckless driving (unless she would have checked on AAD's website).

PlateXchange offers an Open Source system for web sites to communicate license plate packages amongst themselves.

So if you run a license plate based web site, or have a neat idea that you think would take off, but have avoided launching it, because others have something similar, now is your chance to participate in a growing network of niche web sites!

http://www.PlateXchange.com/

posted on Saturday, August 18, 2007 10:34:49 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0]
 
 Tuesday, July 17, 2007
It's been a while since I needed to work with zip files, so when I found myself writing a small routine that periodically downloads and processes a Zip file, I need a quick and cheap (note: by cheap I mean free) method to decompress said file. Of course there are countless number of commercial components available, but most come with a hefty price tag. All I need is to extract a file. Wait, doesn't Windows include the ability to work with compressed folders?

Sure enough, Shell32 (Found in C:\Windows\System32\Shell32.dll) offers methods to extract and create Zips! So with a reference to Microsoft Shell and Automation Controls (Which will create an Interop assembly, Interop.Shell32.Dll), and some handy Googling, I was able to create a small class with 2 methods:
  • UnzipFileTo(zipPath, pathtoExtract): Extracts files in zipPath to pathtoExtract
  • ZipFolder(srcfolderString, dstfolderString): Compresses all files in srcFolderString to dstfolderString

Note: This method does display a Progress Dialog (Even though the proper options have been passed to the CopyHere method), so make sure to handle existing files and paths prior to using.

Below you will find this class in both Visual Basic and C Sharp compatible with Framework 2.0 and above.

Comments and suggestions always welcome!

Visual Basic:

Imports System.IO
Imports Shell32
Public Class ZipControl
    Public ErrorMsg As String = ""
    Public Function UnzipFileTo(ByVal zipPath As String, ByVal pathtoExtract As String) As Boolean
        Try
            Dim sc As New Shell32.ShellClass()
            Dim SrcFlder As Shell32.Folder = sc.NameSpace(zipPath)
            Dim DestFlder As Shell32.Folder = sc.NameSpace(pathtoExtract)
            Dim items As Shell32.FolderItems = SrcFlder.Items()
            DestFlder.CopyHere(items, 4 + 20 + 10 + 200)
        Catch ex As Exception
            Me.ErrorMsg = ex.Message
            Return False
        End Try
        Return True
    End Function
    Public Function ZipFolder(ByVal srcfolderString As String, ByVal dstfolderString As String) As Boolean
        Try
            Dim fileContents() As Byte = {80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
            File.WriteAllBytes(dstfolderString, fileContents)
            Dim oShell As New Shell32.ShellClass
            Dim oFolderSrc As Shell32.Folder
            Dim oFolderDst As Shell32.Folder
            Dim oFolderItems As Shell32.FolderItems
            oFolderSrc = oShell.NameSpace(srcfolderString)
            oFolderDst = oShell.NameSpace(dstfolderString)
            oFolderItems = oFolderSrc.Items()
            oFolderDst.CopyHere(oFolderItems, 4 + 20 + 10 + 200)
        Catch ex As Exception
            Me.ErrorMsg = ex.Message
            Return False
        End Try
        Return True
    End Function
End Class

C#:

using System;
using Shell32;
using System.IO;
public class ZipControl
{
    public string ErrorMsg = "";
    public bool UnzipFileTo(string zipPath, string pathtoExtract)
    {
        try
        {
            Shell32.ShellClass sc = new Shell32.ShellClass();
            Shell32.Folder SrcFlder = sc.NameSpace(zipPath);
            Shell32.Folder DestFlder = sc.NameSpace(pathtoExtract);
            Shell32.FolderItems items = SrcFlder.Items();
            DestFlder.CopyHere(items, 4 + 20 + 10 + 200);
        }
        catch (Exception ex)
        {
            this.ErrorMsg = ex.Message;
            return false;
        }
        return true;
    }
    public bool ZipFolder(string srcfolderString, string dstfolderString)
    {
        try
        {
            byte[] fileContents = {80, 75, 5, 6, 0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0, 0};
            File.WriteAllBytes(dstfolderString, fileContents);
            Shell32.ShellClass oShell = new Shell32.ShellClass();
            Shell32.Folder oFolderSrc;
            Shell32.Folder oFolderDst;
            Shell32.FolderItems oFolderItems;
            oFolderSrc = oShell.NameSpace(srcfolderString);
            oFolderDst = oShell.NameSpace(dstfolderString);
            oFolderItems = oFolderSrc.Items();
            oFolderDst.CopyHere(oFolderItems, 4 + 20 + 10 + 200);
        }
        catch (Exception ex)
        {
            this.ErrorMsg = ex.Message;
            return false;
        }
        return true;
    }
}

posted on Tuesday, July 17, 2007 12:30:42 AM (Eastern Standard Time, UTC-05:00)  #    Comments [1]