[
  {
    "Id": "893243",
    "ThreadId": "389603",
    "Html": "\r\n<p>So far I have used this library with great satisfaction. But right now I have reviewed the documentation and for the life of me cannot get the multiple files to extract to the web location. I have changed the web location to mapped files drives but I am\r\n still not getting any response.&nbsp; Basically, If I comment out the using block the debugger runs and shows that all the rest of the code functions. As soon as I uncomment the using block I never enter the code during debug mode.</p>\r\n<p>I have a event receiver that starts when a new item is added to a web library. If it is a zip file then it should unzip the contents (this will generally be anywhere from 30 to 100 invoices) back to the location it originated from.</p>\r\n<p>All help appreciated.</p>\r\n<div style=\"color:black; background-color:white\">\r\n<pre><span style=\"color:blue\">using</span> Ionic.Zip;\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\">// Use a mapped drive location (mapped to \\\\localhost in case the Zip tool cannot use UNC or Web folders</span>\r\n            <span style=\"color:blue\">string</span> sourceFilePath = &quot;Q:\\\\Invoices\\\\&quot;;\r\n            <span style=\"color:blue\">string</span> targetFilePath = &quot;C:\\\\invoices\\\\&quot;;\r\n\r\n            <span style=\"color:green\">// use the UNC path if the Zip understands them</span>\r\n            <span style=\"color:green\">//string sourceFilePath = &quot;\\\\\\\\ausnb-747218\\\\shared documents\\\\&quot;;</span>\r\n            <span style=\"color:green\">//string targetFilePath = &quot;\\\\\\\\ausnb-747218\\\\shared documents\\\\&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 a 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\">// test code line to ensure if statements are functioning</span>\r\n                    <span style=\"color:green\">// string testFileName = fileName;</span>\r\n                    <span style=\"color:green\">//it's a zip so use the ionic.zip.dll known as dotnetzip</span>\r\n                    \r\n                    <span style=\"color:blue\">using</span> (ZipFile zip = ZipFile.Read(sourceFile))\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(targetFilePath);\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n}\r\n</pre>\r\n</div>\r\n<p>!</p>\r\n",
    "PostedDate": "2012-07-30T12:45:03.143-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]