2
我一直在使用功能的PowerShell要解壓的大量文件:解壓在PowerShell中不清除臨時文件
function Expand-ZIPFile($file, $destination)
{
$shell = new-object -com shell.application
$zip = $shell.NameSpace($file)
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}
我稱之爲使用類似:
Expand-ZIPFile -File "$dir\$zip_file" -Destination $work_dir
我發現這個過程在創建一個臨時文件 C:\ Documents and Settings \ ftpuser \ Local Settings \ Temp
對於這些文件中的每一個我都解壓縮了,過去mont它已經生成了近800GB的臨時文件。
問:是否有一種方法來
- 從擺在首位創建一個臨時文件停止解壓過程?
- 強制我的腳本在退出之前清理這些文件?
我無法在Windows 7中複製這種行爲,這也觀察到這裏(http://forums.anandtech.com/showthread.php?t=2217442)。不理想,但我想你可以從%temp%目錄清空最近的文件。說..最後10分鐘編輯? – Matt 2014-10-18 03:09:47
我會注意到,創建或解壓縮zip文件的Shell.Application破解不是自動化友好的(沒有狀態檢查,它是異步的等)。看到這裏:[http://social.msdn.microsoft.com/Forums/vstudio/en-US/760ea95b-4c3e-4f48-a0f6-9d728d5580da/](http://social.msdn.microsoft.com/Forums/ vstudio/EN-US/760ea95b-4c3e-4f48-a0f6-9d728d5580da /)。使用命令行解壓縮工具(例如[7-Zip](http://www.7-zip.org))的99%時間更簡單。 – 2014-10-18 16:08:45