Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

compress (zipped) folders issue

已查看 2,227 次
跳至第一个未读帖子

RdS

未读,
2007年12月3日 20:54:002007/12/3
收件人
hi,

I am performing the following which works perfectly if there is not an empty
subdirectory within the folder I am trying to zip.


src = "c:\temp\"
dest = "c:\test\test1.zip"

'write zip file header
set fso = createobject("Scripting.FileSystemObject")
set file = fso.opentextfile(dest,forwriting,true)
file.write "PK" & chr(5) & chr(6) & string(18,chr(0))
file.close

set shl = createobject("Shell.Applicatioin")
shl.namespace(dest).copyhere shl.namespace(src).items
do until shl.namespace(dest).items.count = shl.namespace(src).items.count
wscript.sleep 100
loop

However, if there is an empty subdirectory I receive the following error
"The specified directory c:\temp\vbe is empty, so compressed (zipped) folders
cannot add it to the archive.

How do I prevent this from happening. If I do the same thing manually by
right clicking on temp and choosing send to\compressed folder I do not
receive the error.

thanks.

WenYuan Wang [MSFT]

未读,
2007年12月4日 06:48:412007/12/4
收件人
Hello RdS,

I understood your issue is that VBScript throw an error when tring to
insert an empty subdirectory into compress(zip) folder. If I misunderstood
anything here, please feel free to correct me.

If this is the case, I have reproduced it on my side.
We need to perform more research on this issue . We will reply here as soon
as possible. If you have any more concerns on it, please feel free to post
here.

Thanks for your understanding!
Best regards,

Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

WenYuan Wang [MSFT]

未读,
2007年12月5日 04:30:422007/12/5
收件人
Hello Rds,
Thanks for your waiting.

This error will be thrown when we drop an Empty Directory into Compress
(zipped) folders. You can try it in Windows Explorer.
"Send to compressed folder" does not copy items into Target Compress folder
directly. It warps them in a folder. Thereby, we didn't received error when
compress a folder with an empty subdirectory.

Try the following method can resolve this issue.
set shl = CreateObject("Shell.Application")
shl.namespace(dest).copyhere shl.namespace(src).self
do until shl.namespace(dest).items.count = 1
wscript.sleep 100
loop

Hope this helps, please feel free to update here again, if there is
anything unclear. We are glad to assist you.

Have a great day,

RdS

未读,
2007年12月5日 18:28:002007/12/5
收件人
Thanks a lot. Is there any way to use compressed (zipped) folders from FSO
as it is very reliable.

have read lots about shell not being so dependable.

Also, I have tried using the options specified in the copyhere docs on MSDN
and have had no success. I don't want progress windows or windows to be
displayed if there is an issue. I want to trap them. :)

thanks again.

WenYuan Wang [MSFT]

未读,
2007年12月7日 02:49:092007/12/7
收件人
Hello Rds,
Thanks for your reply.

I consulted shell team. Windows XP or above handles Zip files by
zipfldr.dll (which is located in %windir%\system32\zipfldr.dll). It's a
thrid party product. I'm sorry to say Microsoft doesn't provide any API to
compress Zip via zipfldr.dll.

The MSDN documentation you referenced about CopyHere method only applies to
normal file system path.It doesn't work for a zip file folder. That's why
you find the option 4 to disable the progress dialog doesn't help.It's by
desgin.

By the way, currently the zip file functionality is only meant to be used
with User Interaction. In other words, programmatically access to the zip
file NSE is not officially supported.

Hope this helps.

neoge...@gmail.com

未读,
2013年3月15日 10:21:002013/3/15
收件人
hi, i myself am looking for a code, but i want to zip multiple files into a zip, for example, zip all files thats named "anything" in this folder, using winrar, can anybody help

R.Wieser

未读,
2013年3月16日 06:46:572013/3/16
收件人
Hey neogenics, I think you can use this:

http://www.techcoil.com/blog/handy-vbscript-functions-for-dealing-with-zip-f
iles-and-folders/

-- Origional message:
<neoge...@gmail.com> schreef in berichtnieuws
a5b46f8a-87a0-47d9...@googlegroups.com...
0 个新帖子