[
  {
    "Id": "895207",
    "ThreadId": "390179",
    "Html": "\r\n<p>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\r\n am I doing wrong?</p>\r\n<p></p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre><span style=\"color:blue\">using</span> Ionic.Zip;\r\n<span style=\"color:blue\">using</span> Microsoft.SharePoint;\r\n<span style=\"color:blue\">using</span> Microsoft.SharePoint.Security;\r\n<span style=\"color:blue\">using</span> Microsoft.SharePoint.Utilities;\r\n<span style=\"color:blue\">using</span> Microsoft.SharePoint.Workflow;\r\n<span style=\"color:blue\">using</span> System;\r\n<span style=\"color:blue\">using</span> System.Diagnostics;\r\n<span style=\"color:blue\">using</span> System.Collections;\r\n<span style=\"color:blue\">using</span> System.Collections.ObjectModel;\r\n<span style=\"color:blue\">using</span> System.IO;\r\n<span style=\"color:blue\">using</span> System.IO.Compression;\r\n<span style=\"color:blue\">using</span> System.Security.Permissions;\r\n\r\n\r\n\r\n<span style=\"color:blue\">namespace</span> CL.Receiver.Invoices.InvoiceZipAdded\r\n{\r\n    <span style=\"color:gray\">///</span> <span style=\"color:gray\">&lt;summary&gt;</span>\r\n    <span style=\"color:gray\">///</span><span style=\"color:green\"> List Item Events</span>\r\n    <span style=\"color:gray\">///</span> <span style=\"color:gray\">&lt;/summary&gt;</span>\r\n    <span style=\"color:blue\">public</span> <span style=\"color:blue\">class</span> InvoiceZipAdded : SPItemEventReceiver\r\n    {\r\n        <span style=\"color:gray\">///</span> <span style=\"color:gray\">&lt;summary&gt;</span>\r\n        <span style=\"color:gray\">///</span><span style=\"color:green\"> An invoice zip file was added and requires unzipping</span>\r\n        <span style=\"color:gray\">///</span> <span style=\"color:gray\">&lt;/summary&gt;</span>\r\n        <span style=\"color:blue\">public</span> <span style=\"color:blue\">override</span> <span style=\"color:blue\">void</span> ItemAdded(SPItemEventProperties properties)\r\n        {\r\n            <span style=\"color:green\">// read properties from the item after adding to the library</span>\r\n            <span style=\"color:blue\">base</span>.ItemAdded(properties);\r\n            <span style=\"color:blue\">string</span> afterURL = properties.AfterUrl;\r\n            <span style=\"color:blue\">string</span> fileExtension = afterURL.Substring(afterURL.LastIndexOf(<span style=\"color:#a31515\">'.'</span>) &#43; 1);\r\n            <span style=\"color:blue\">string</span> fileName = afterURL.Substring(afterURL.LastIndexOf(<span style=\"color:#a31515\">'/'</span>) &#43; 1);\r\n\r\n            <span style=\"color:green\">// using local drives only until I get DotNetZip to function ignoring the actual web file that kicks this off</span>\r\n            <span style=\"color:green\">// except to drive the event into the unzip process</span>\r\n            <span style=\"color:blue\">string</span> sourceFilePath = <span style=\"color:#a31515\">@&quot;c:\\windowspowershell\\&quot;</span>;\r\n            <span style=\"color:blue\">string</span> targetFilePath = <span style=\"color:#a31515\">@&quot;c:\\windowspowershell\\test\\&quot;</span>;\r\n            <span style=\"color:blue\">string</span> sourceFile = sourceFilePath &#43; fileName;\r\n\r\n            <span style=\"color:green\">// unzip it if it is an invoice zip file and is from the correct directory</span>\r\n            <span style=\"color:blue\">if</span> (fileExtension == <span style=\"color:#a31515\">&quot;zip&quot;</span>) \r\n            {\r\n                <span style=\"color:blue\">if</span> (afterURL == <span style=\"color:#a31515\">&quot;Invoices/&quot;</span> &#43; fileName)\r\n                {\r\n                    <span style=\"color:green\">// code drives into this line and this line reads correctly as</span>\r\n                    <span style=\"color:green\">// letsUnzip(&quot;c:\\\\windowspowershell\\\\&quot;, c:\\\\windowspowershell\\\\test\\\\&quot;)</span>\r\n                    <span style=\"color:green\">// breakpoint set on next line</span>\r\n                     letsUnzip(sourceFile, targetFilePath);\r\n                    <span style=\"color:green\">// code never gets past here and there are no error messages, it just falls through</span>\r\n                }\r\n            }\r\n        }\r\n        <span style=\"color:blue\">public</span> <span style=\"color:blue\">void</span> letsUnzip(<span style=\"color:blue\">string</span> theSource, <span style=\"color:blue\">string</span> theTarget)\r\n        {\r\n            <span style=\"color:green\">// program drops into here and displays the next line fine until I uncomment the </span>\r\n            <span style=\"color:green\">// using line and below to actually unzip the file contents</span>\r\n            \r\n            <span style=\"color:green\">// test line</span>\r\n            <span style=\"color:blue\">string</span> testFileName = theSource;\r\n\r\n            <span style=\"color:green\">// if commented out the above line works</span>\r\n            <span style=\"color:green\">// if not commented out, code never gets here (breakpoint set at 'public')</span>\r\n            <span style=\"color:blue\">using</span> (ZipFile zip = ZipFile.Read(theSource))\r\n            {\r\n                <span style=\"color:blue\">foreach</span> (ZipEntry entry <span style=\"color:blue\">in</span> zip)\r\n                {\r\n                    entry.Extract(theTarget);\r\n                }\r\n            }\r\n        }    \r\n    }\r\n}\r\n</pre>\r\n</div>\r\n<p></p>\r\n",
    "PostedDate": "2012-08-03T08:14:14.99-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "896020",
    "ThreadId": "390179",
    "Html": "<p>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.</p>\r\n<p>Thanks to those that took a stab at this for me!</p>\r\n<p>Greg</p>",
    "PostedDate": "2012-08-06T06:41:19.823-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]