不使用zip32.dll打包的方法

来源:互联网 发布:linux查看内存插槽 编辑:程序博客网 时间:2024/06/16 15:17

Dim fso As New Scripting.FileSystemObjectDim Shell As ObjectDim zFolder As ObjectDim sFolder As ObjectDim zipFile As StringDim f As ObjectDim FileName As StringDim sFolderItem As ObjectzipFile = "Sample" & ".zip"FSO.CreateTextFile(zipFile, False).Write "PK"&Chr(5)&Chr(6)&String(18, 0)Set Shell = CreateObject("Shell.Application")Set zFolder = Shell.Namespace(FSO.GetAbsolutePathName(zipFile))set sFolder = Shell.Namespace(FSO.GetAbsolutePathName(sourcePath))For Each f In FSO.GetFolder(sourcePath).FilesFileName = FSO.GetFileName(f)Set sFolderItem = Shell.Namespace(FSO.GetParentFolderName(FSO.GetAbsolutePathName(f))).ParseName(FileName)zFolder.CopyHere sFolderItemNextFor Each XXX.SubFOldersApplication.Wait Now+TimeSerial(0, 0, 1)//如果没有这句话,会生成空白文件----------------------------------------------------------------------------------------------------------//以下的写法更标准Set zFolderItem zFolder.ParseName(FileName)If zFolderItem Is Nothing ThenCount = zFolder.Items.CountzFolder.CopyHere sFolderItemDo While zFolder.Items().Count = CountApplication.wait Now + TimeSerial(0, 0, 1)LoopEnd IfNext...


0 0
原创粉丝点击