[
  {
    "Id": "556892",
    "ThreadId": "243689",
    "Html": "\r\n<p>During the zip process, a temporary file is created.&nbsp; Can I set the property of where this temporary file should exist during the zipping process?&nbsp; I don't have enough space for it on the source or target drives.</p>\r\n<p>Detail:</p>\r\n<p>Here is the powershell function I use to zip up.</p>\r\n<p>[system.reflection.assembly]::LoadFrom(&quot;c:\\bkp\\Ionic.Zip.dll&quot;)</p>\r\n<p>function global:dotnetzip<br>\r\n{<br>\r\n&nbsp;&nbsp;&nbsp; #using&nbsp; dotnetzip &quot;c:\\SourceFolder&quot; &quot;c:\\destination.zip&quot; &quot;FolderNameInsideRootOfZip&quot;<br>\r\n&nbsp;&nbsp;&nbsp; # http://dotnetzip.codeplex.com/Wiki/View.aspx?title=PS-Examples<br>\r\n&nbsp;&nbsp;&nbsp; #[system.reflection.assembly]::LoadFrom(&quot;c:\\bkp\\Ionic.Zip.dll&quot;)<br>\r\n&nbsp;&nbsp;&nbsp; <br>\r\n&nbsp;&nbsp;&nbsp; <br>\r\n&nbsp;&nbsp;&nbsp; $source = $args[0]<br>\r\n&nbsp;&nbsp;&nbsp; $destinationinput = $args[1]<br>\r\n&nbsp;&nbsp;&nbsp; $FolderName = $args[2]<br>\r\n&nbsp;&nbsp;&nbsp; <br>\r\n&nbsp;&nbsp;&nbsp; &quot;Will zip $source to $destinationinput under $FolderName&quot; | Out-File $logfilename -Append<br>\r\n&nbsp;&nbsp;&nbsp; <br>\r\n&nbsp;&nbsp;&nbsp; $destinationobject = $null<br>\r\n<br>\r\n&nbsp;&nbsp;&nbsp; $destinationobject = new-object Ionic.Zip.ZipFile<br>\r\n&nbsp;&nbsp;&nbsp; $Zip64 = new-object Ionic.Zip.Zip64Option<br>\r\n&nbsp;&nbsp;&nbsp; $Zip64.value__ = $true<br>\r\n&nbsp;&nbsp;&nbsp; <br>\r\n&nbsp;&nbsp;&nbsp; $destinationobject.UseZip64WhenSaving = $Zip64<br>\r\n&nbsp;&nbsp;&nbsp; <br>\r\n&nbsp;&nbsp;&nbsp; $destinationobject.AddDirectory($source, $FolderName)<br>\r\n&nbsp;&nbsp;&nbsp; $destinationobject.save($destinationinput)<br>\r\n}</p>\r\n<p>To call the function, I do:</p>\r\n<p>dotnetzip &quot;$vhdpath&quot; &quot;$zipfilename&quot; &quot;$vhdzipname&quot;</p>\r\n<p>------------------------------------------------------------------</p>\r\n<p>Now, (just as an fyi) with this small test script, I can find a drive on the server that has the most space and check for a minimum amount:</p>\r\n<p>$freedrive = $null<br>\r\n$drivelist = Get-PSDrive -PSProvider filesystem <br>\r\n<br>\r\n[array]$drivearray = $drivelist | Sort-Object Free -Descending | Where-Object {$_.Free -ne $null}<br>\r\nif ($drivearray[0].free -ge &quot;5000000000&quot;){ # 5 gigs or more<br>\r\n&nbsp;&nbsp;&nbsp; $freedrive = $drivearray[0].root<br>\r\n}<br>\r\n<br>\r\n$templocation = ($freedrive &#43; &quot;test.txt&quot;)</p>\r\n<p>#creates file to verify process worked<br>\r\nNew-Item $templocation -type file</p>\r\n<p>------------------------------------------------------------------</p>\r\n<p>I have checkout out my $destinationobject object with get-member to see if there is anything there to set the location of the temporary file, along with other objects.&nbsp; I cannot see anything there to do this.</p>\r\n<p>When I call the $destinationobject.AddDirectory($soruce, $foldername) method, I get a listing of properties.&nbsp; (LastModified, ModifiedTime, AccessedTime, CreatedTime, EmitTimesInWindowsFormatWhenSaving, EmitTimeInUnixFormatWhenSaving, Timestamp, Attributes,\r\n ForceNoCompression, Filename, InputStream, InputStreamWasJitProvided, Source, VersionNeeded, Comment, RequiresZip64, BitField, CompressionMethod, CompressedSize, UncompressedSize, CompressionRatio, Crc, IsDirectory, UsesEncryption, Encryption, Password, OverwriteOnExtract,\r\n ExtractExistingFile, ZipErrorAction, IncludedInMostRecentSave, WillReadTwiceOnInflation, WantCompression, UseUnicodeAsNecessary, ProvisionalAlternateEncoding, ActualEncoding, IsText)</p>\r\n<p>------------------------------------------------------------------</p>\r\n<p>To summarize, I want to put this all together and point the temporary zip job file to a specific drive ad hoc.&nbsp; Where to do I find the property to tell the zip method where to put this temp file?</p>\r\n<p>Thanks!!</p>\r\n",
    "PostedDate": "2011-01-28T07:26:22.81-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "558064",
    "ThreadId": "243689",
    "Html": "\r\n<p>Yes, see the TempFileFolder property. <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/html/84805b08-61c0-9af8-7a3a-a33d331243f8.htm\">\r\nhttp://cheeso.members.winisp.net/DotNetZipHelp/html/84805b08-61c0-9af8-7a3a-a33d331243f8.htm</a></p>\r\n<p>I know it's tempting to just use introspection when working with an environment like POwershell, but the documentation is pretty complete and it talks about these things.</p>\r\n<p>I recommend it highly.&nbsp; <a href=\"http://cheeso.members.winisp.net/DotNetZipHelp/frames.htm\">\r\nhttp://cheeso.members.winisp.net/DotNetZipHelp/frames.htm</a></p>\r\n<p>BUT - I think you may have a misunderstanding of how the temp file works. If you are zipping up a folder, say f:\\files\\data , and storing that to a zipfile named c:\\archives\\1.zip , the temp file is created in c:\\archives . There is no extra space required\r\n for temp files in c:\\archives beyond the size of the zipfile itself.&nbsp; If your zip is 1gb, then your temp file will start small, grow to 1gb, then DotNetZip will rename it to the final zipfile name.&nbsp; So, if you have enough space to store the final\r\n zip file, then you have enough&nbsp;space&nbsp;for the temp file.&nbsp; The only time a copy is performed is when you set the TempFileFolder to something other than the folder for the final zip file.&nbsp; In that case DotNetZip performs a copy, which essentially\r\n doubles your space requirements for any given zip file.&nbsp;</p>\r\n<p>Setting TempFileFolder will not solve the problem you are describing, if I understand it correctly.&nbsp; If you have enough space to store the zipfile, then you have enough space for the temp file and you shouldn't need to set TempFileFolder.&nbsp; If you\r\n have enough space on f:\\, then save it to f:\\.&nbsp; If you have enough space on g:\\, then save the zipfile to g:\\.&nbsp; I recommend avoiding setting the TempFileFolder explicitly, unless you have some special requirement.</p>\r\n<p>&nbsp;</p>\r\n<p>&nbsp;</p>\r\n",
    "PostedDate": "2011-01-31T05:53:43.887-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "559637",
    "ThreadId": "243689",
    "Html": "\r\n<p>Thanks!&nbsp; I'll take another look at the setup.&nbsp; Thanks for the doc link.</p>\r\n",
    "PostedDate": "2011-02-02T11:43:53.003-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]