enter code here
''我在路径中有一个文件,如下所示:
'' D:\发展\ Efforts.csv float:left
''需要检查Efforts.csv是否存在,如果存在,请执行以下操作
''将文件Efforts.csv压缩到Efforts.zip并删除原来的Efforts.csv **
答案 0 :(得分:0)
Dim fso 设置fso = CreateObject(“Scripting.FileSystemObject”)
Const FOF_CREATEPROGRESSDLG =& H0&
Const MyZip =“D:\ Sravan \ zip \ zipthefile.zip”
Const File1 =“D:\ Sravan \ zip \ zipthefile.txt”
'Const MyDest =“C:\ scratch”'可以使用此var,如果您需要在完成后移动拉链我想。不知道为什么他实际上把它留在这里:)
'--------------创建空的zip文件---------
'创建zip文件的基础。 CreateObject(“Scripting.FileSystemObject”)_ .CreateTextFile(MyZip,True)_ 。写“PK”& Chr(5)& Chr(6)&字符串(18,vbNullChar)
'-------------- zip ---------------------------
'准备好将文件添加到zip 使用CreateObject(“Shell.Application”)
'添加文件 .NameSpace(MyZip).MoveHere File1,FOF_CREATEPROGRESSDLG
结束 wScript.Sleep 1000
wscript.echo“完成!”
答案 1 :(得分:0)
'The location of the zip file.
ZipFile="C:\TestStare.zip"
'The folder the contents should be extracted to.
ExtractTo="C:\ExtractTestStare\"
'If the extraction location does not exist create it.
Set fso = CreateObject("Scripting.FileSystemObject")
If NOT fso.FolderExists(ExtractTo) Then
fso.CreateFolder(ExtractTo)
End If
'Extract the contants of the zip file.
set objShell = CreateObject("Shell.Application")
set FilesInZip=objShell.NameSpace(ZipFile).items
objShell.NameSpace(ExtractTo).CopyHere(FilesInZip)
Set fso = Nothing
Set objShell = Nothing