[
  {
    "Id": "1067630",
    "ThreadId": "449837",
    "Html": "Hi Dino,<br />\n<br />\n(Note:  I’m addressing this post to Dino only because I’m suggesting there <em>may</em> be a bug in the library.  However, all comments, especially those containing helpful suggestions, are welcome.)  I apologize for the length of this post, but it takes quite a bit of space to communicate all the necessary information.<br />\n<br />\nI’ve been struggling for several weeks to create a Powershell script that uses DotNetZip to archive (zip) a set of nested folders, and I think I’ve run into a bug in the library.  I’ll lay it out for you, and maybe you can tell me what’s going on. <br />\n<br />\nI'm running under Windows 7 SP1 Professional and PowerShell 3.0.<br />\n<br />\nI’m using a slight modification of your ZipUp-Files script at the DotNetZip Home Page on MSDN.  (<a href=\"http://archive.msdn.microsoft.com/DotNetZip/Wiki/View.aspx?title=PowerShell%20Example&amp;referringTitle=Home\" rel=\"nofollow\">http://archive.msdn.microsoft.com/DotNetZip/Wiki/View.aspx?title=PowerShell%20Example&referringTitle=Home</a>)  At least I was going to <strong>start</strong> there.  Unfortunately, I didn’t get very far, because of this <em>alleged</em> bug.<br />\n<br />\nHere is my script as it stands now.  Most of the changes I’ve made deal with file and directory names to make the script compatible with my machine’s filesystem.<br />\n<pre><code>function ZipUp-Files ( $directory )\n{\n  $children = get-childitem -path $directory\n  foreach ($o in $children) \n  {\n    if (!$BaseDir -or ($BaseDir -eq &quot;&quot;)) {\n      $ix = $o.PSParentPath.IndexOf(&quot;::&quot;)\n      $BaseDir = $o.PSParentPath.Substring($ix+2)\n      $x = get-item $BaseDir\n      $ix = $x.PSParentPath.IndexOf(&quot;::&quot;)\n      $ParentOfBase = $x.PSParentPath.Substring($ix+2) + &quot;\\&quot;\n    }\n \n    if ($o.Name -ne &quot;TestResults&quot; -and \n        $o.Name -ne &quot;obj&quot; -and \n        $o.Name -ne &quot;bin&quot; -and\n       $o.Name -ne &quot;NTUSER.DAT&quot; -and\n    $o.Name -ne &quot;_tfs&quot; -and \n    $o.Name -ne &quot;notused&quot; -and \n    $o.Name -ne &quot;AppNote.txt&quot; -and \n    $o.Name -ne &quot;CodePlex-Readme.txt&quot; -and \n    $o.Name -ne &quot;ReadThis.txt&quot; -and \n    $o.Name -ne &quot;Ionic.snk&quot; -and \n    $o.Name -ne &quot;Ionic.pfx&quot; -and \n    $o.Name -ne &quot;Debug&quot; -and \n    $o.Name -ne &quot;Release&quot; -and\n    $o.Name -ne &quot;Resources&quot;)\n    {\n      if ($o.PSIsContainer)\n      {\n        ZipUp-Files ( $o.FullName )\n      }\n      else \n      {\n        #Write-output $o.FullName\n        if ($o.Name  -and\n          $o.Name -ne &quot;&quot; -and\n          $o.Name -ne &quot;.tfs-ignore&quot; -and\n          (!$o.Name.EndsWith(&quot;~&quot;)) -and\n          (!$o.Name.EndsWith(&quot;#&quot;)) -and\n          (!$o.Name.EndsWith(&quot;.cache&quot;)) -and\n          (!$o.Name.EndsWith(&quot;.zip&quot;) )\n        )\n        {\n          Write-output $o.FullName.Replace($ParentOfBase, &quot;&quot;)\n          $e= $zipfile.AddFile($o.FullName.Replace($ParentOfBase, &quot;&quot;))\n        }\n      }\n    }\n  }\n}\n\n\n$DotNetZip='C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\DotNetZip'\n$DNZ = $DotNetZip\n$PS = 'C:\\PSScripts'       # Development area for my PowerShell scripts\n\nRemove-Item 'c:\\DotNetZip-src-v.zip' -Force -ea SilentlyContinue\n\n[System.Reflection.Assembly]::LoadFrom($DNZ+'\\Ionic.Zip.Dll') \n# [System.Reflection.Assembly]::LoadFrom(&quot;c:\\\\dinoch\\\\bin\\\\Ionic.Zip.dll&quot;);\n$version = get-content -path $DNZ'\\AssemblyInfo.cs' | select-string -pattern 'AssemblyFileVersion\\(&quot;[0-9]+(\\.([0-9]+|\\*)){1,3}&quot;\\)'  |  %{$_ -replace &quot;[^0-9.]&quot;,&quot;&quot;}\n\n$ZipFileName = 'c:\\DotNetZip-src-v.zip'\n$zipfile =  new-object Ionic.Zip.ZipFile($ZipFileName);\ncd $DNZ; cd ..\nZipUp-Files &quot;DotNetZip&quot;\n$zipfile.Save()\n$zipfile.Dispose()\n\ncd $PS\n</code></pre>\n\nAs suggested by $DotNetZip= immediately after the <em>function</em> portion of the script, on my machine, Powershell is installed at C:\\Windows\\System32\\WindowsPowerShell\\v1.0, and DotNetZip is stored in a directory therein.  For the ISE host, that is sufficient. The variable $DotNetZip points to that directory, and Powershell_ISE is happy.  I can run the script, which I have called <em>ZipUp-Files-WFM.ps1</em> in that host all day long.<br />\n<br />\nHowever, the Console-Host is an entirely story:  when I attempt to run ZipUp-Files-WFM under simply Powershell, it results in an abnormal termination, with the following messages at the end.<br />\n<pre><code>. . . . . . . . . . . . . . . . . . . . . .\n\nDotNetZip\\License.zlib.txt\nDotNetZip\\License_1.txt\nDotNetZip\\PleaseDonate.txt\nDotNetZip\\PleaseDonate_1.txt\nDotNetZip\\Readme.txt\nDotNetZip\\Readme_1.txt\nDotNetZip\\Zipit.exe\nException calling &quot;Save&quot; with &quot;0&quot; argument(s): &quot;C:\\Users\\Walter\\DotNetZip\\Apps\\ConvertFromCS-Zip.ps1&quot;\nAt C:\\PSScripts\\ZipUp-Files-WFM.ps1:68 char:1\n+ $zipfile.Save()\n+ ~~~~~~~~~~~~~~~\n    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException\n    + FullyQualifiedErrorId : FileNotFoundException\n</code></pre>\n\nTo me most of the error message is essentially nonsense.  Maybe it means more to you.<br />\n<br />\nThe reason I <em>suspect</em> there is bug is that neither my $profile nor my script make any reference to the <em>C:\\Users\\Walter</em> directory, other than indirectly through $(PS)Home preference variables.<br />\n<br />\nFurthermore, most of the method calls to Ionic.Zip.dll are content to use the $Home directory, and do so correctly.  Only the Save() method call fails, and when it does, it yanks an (incorrect) pathname out of thin air.  To me, that strongly suggests a bug somewhere in the method code.<br />\n<br />\nThanks in advance for your help,<br />\n<br />\nWalter<br />\n",
    "PostedDate": "2013-07-12T11:39:07.927-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "1496984",
    "ThreadId": "449837",
    "Html": "Did you ever manage to get a solution to this? I've got a very similar problem, the save() method seems to be pulling a filename out of thin air. I've tried setting the filename when creating the object, as well as passing the filename to the save method, still ignores it and uses FTP.log in my users folder, for some reason. output - <br />\n<pre><code>Exception calling &quot;Save&quot; with &quot;1&quot; argument(s): &quot;C:\\Users\\cameron\\FTP.log&quot;\nAt line:28 char:1\n+ $zipFile.Save(&quot;e:\\temp\\logs\\test.zip&quot;)\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException\n    + FullyQualifiedErrorId : FileNotFoundException</code></pre>\n\nI had a quick look through the source code, and can't see anywhere where it's picking up the user folder, so no idea where it's getting that from. <br />\n",
    "PostedDate": "2017-06-08T23:21:55.55-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]