MyException - 我的異常網
當前位置:我的異常網» vbScript » [QTP]vbscript對資料或文件夾進行打包與解包

cf手游新版本更新时间:[QTP]vbscript對資料或文件夾進行打包與解包

cf手游刷枪永久枪软件 www.yqwdk.icu  網友分享于:2013-01-29  瀏覽:26次
[QTP]vbscript對文件或文件夾進行打包與解包

cf手游刷枪永久枪软件 www.yqwdk.icu vbscript對文件或文件夾進行打包與解包

在自動化測試工作中,有時會用到對文件或文件夾進行打包或解包,經過一番研究,我們可以通過CreateObject非常輕松地實現所需要的功能。

首先,需要在操作系統中注冊XZip.dll,以管理員身份:Regsvr32 "XZip.dll文件路徑"

在//www.xstandard.com/en/documentation/xzip/地址可以下載到該DLL,這里也有它的使用范例講解,目前可以支持以下平臺:

?For Windows 2000, XP, Vista, Windows 7: IE 5.0+, Firefox 1.0+, Safari 3.0+ or Opera 9.0+
?For OS X 10.3.9+: Firefox 1.0+ or Safari 1.3+

例如:將C:\test\xifeijian.jpg打包成C:\test.zip

Dim objZip
set objZip=createobject("XStandard.zip")
objZip.Pack "C:\test\xifeijian.jpg","C:\test.zip"
Set objZip=nothing

Examples

The examples below are for Active Server Pages. For Windows Scripting Host or Visual Basic, replaceServer.CreateObject withCreateObject and replaceResonse.Write withMsgBox.

How to archive (or zip) multiple files

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Pack "C:\Temp\golf.jpg", "C:\Temp\images.zip"
  5. objZip.Pack "C:\Temp\racing.gif", "C:\Temp\images.zip"
  6. Set objZip = Nothing
  7. %>

How to archive (or zip) multiple files with different compression levels

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Pack "C:\Temp\reports.doc", "C:\Temp\archive.zip", , , 9
  5. objZip.Pack "C:\Temp\boat.jpg", "C:\Temp\archive.zip", , , 1
  6. Set objZip = Nothing
  7. %>

How to archive (or zip) multiple files with default path

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Pack "C:\Temp\reports.doc", "C:\Temp\archive.zip", True
  5. objZip.Pack "C:\Temp\boat.jpg", "C:\Temp\archive.zip", True
  6. Set objZip = Nothing
  7. %>

How to archive (or zip) multiple files with a custom path

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Pack "C:\Temp\reports.doc", "C:\Temp\archive.zip", True, "files/word"
  5. objZip.Pack "C:\Temp\boat.jpg", "C:\Temp\archive.zip", True, "files/images"
  6. Set objZip = Nothing
  7. %>

How to archive (or zip) multiple files using wildcards

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Pack "C:\Temp\*.jpg", "C:\Temp\images.zip"
  5. Set objZip = Nothing
  6. %>

How to unzip files

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.UnPack "C:\Temp\images.zip", "C:\Temp\"
  5. Set objZip = Nothing
  6. %>

How to unzip files using wildcards

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.UnPack "C:\Temp\images.zip", "C:\Temp\", "*.jpg"
  5. Set objZip = Nothing
  6. %>

How to get a listing of files and folder in an archive

  1. <%
  2. Dim objZip, objItem
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. For Each objItem In objZip.Contents("C:\Temp\images.zip")
  5. Response.Write objItem.Path & objItem.Name & "<br />"
  6. Next
  7. Set objZip = Nothing
  8. Set objItem = Nothing
  9. %>

How to remove a file from an archive

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Delete "headshots/smith.jpg", "C:\Temp\images.zip"
  5. Set objZip = Nothing
  6. %>

How to move a file in an archive

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Move "headshots/jones.jpg", "staff/jones.jpg", "C:\Temp\images.zip"
  5. Set objZip = Nothing
  6. %>

How to rename a file in an archive

  1. <%
  2. Dim objZip
  3. Set objZip = Server.CreateObject("XStandard.Zip")
  4. objZip.Move "headshots/jones.jpg", "headshots/randy-jones.jpg", "C:\Temp\images.zip"
  5. Set objZip = Nothing
  6. %>

Known Issues

  • The UnPack() method will first remove all files from the destination folder. This behavior will change in future releases.
  • This component was not designed to work with huge archives. Max archive size depends on the amount of available RAM.
  • This component is designed for 32-bit operating systems and will not work natively on 64-bit operating systems.

文章評論

軟件開發程序錯誤異常cf手游刷枪永久枪软件Copyright © 2009-2015 MyException 版權所有