Code never runs

Aug 3, 2012 at 3:14 PM

The following code works up to the point where I call the unzip process. If I comment out the code and put in some string to display what the text strings are then it drops into the routine. Put the using portion back in and it drops through again. What am I doing wrong?

using Ionic.Zip;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.ObjectModel;
using System.IO;
using System.IO.Compression;
using System.Security.Permissions;

namespace CL.Receiver.Invoices.InvoiceZipAdded
    /// <summary>
    /// List Item Events
    /// </summary>
    public class InvoiceZipAdded : SPItemEventReceiver
        /// <summary>
        /// An invoice zip file was added and requires unzipping
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
            // read properties from the item after adding to the library
            string afterURL = properties.AfterUrl;
            string fileExtension = afterURL.Substring(afterURL.LastIndexOf('.') + 1);
            string fileName = afterURL.Substring(afterURL.LastIndexOf('/') + 1);

            // using local drives only until I get DotNetZip to function ignoring the actual web file that kicks this off
            // except to drive the event into the unzip process
            string sourceFilePath = @"c:\windowspowershell\";
            string targetFilePath = @"c:\windowspowershell\test\";
            string sourceFile = sourceFilePath + fileName;

            // unzip it if it is an invoice zip file and is from the correct directory
            if (fileExtension == "zip") 
                if (afterURL == "Invoices/" + fileName)
                    // code drives into this line and this line reads correctly as
                    // letsUnzip("c:\\windowspowershell\\", c:\\windowspowershell\\test\\")
                    // breakpoint set on next line
                     letsUnzip(sourceFile, targetFilePath);
                    // code never gets past here and there are no error messages, it just falls through
        public void letsUnzip(string theSource, string theTarget)
            // program drops into here and displays the next line fine until I uncomment the 
            // using line and below to actually unzip the file contents
            // test line
            string testFileName = theSource;

            // if commented out the above line works
            // if not commented out, code never gets here (breakpoint set at 'public')
            using (ZipFile zip = ZipFile.Read(theSource))
                foreach (ZipEntry entry in zip)

Aug 6, 2012 at 1:41 PM

Answer: After testing, and the help of a true SharePoint guru (thank you Todd Bleeker) I finally found the error. In SharePoint it is necessary for the referenced .dll's to be available in the GAC. By add the Ionic name space and the location of the .DLL referenced through the Package 9under the Advanced Tab), the .DLL is automatically included in the deployment and viola - no more errors.

Thanks to those that took a stab at this for me!