asp 可否压缩_怎样用ASP压缩文件
多數(shù)的時候我們需要壓縮文件,保存到特定的位置,或者你可以使用它實現(xiàn)所有你想要的效果。
我們需要服務器支持WScript.Shell-多數(shù)的站長都不會允許這樣的。
這里你可以獲取下載鏈接,在下載這個文件之前你可以要么指定相對的路徑或者是絕對的路徑,然后點擊這里下載。
-zipfile.asp
< %
'---------------------------------------------------------
'CreateZipFile: function to create zip file at particular location 創(chuàng)建Zip文件:在特定位置zip文件的功能
'ZipPath - full path for the zip file, including the zip file name. Zip路徑--zip文件的完整路徑,包括zip文件名
'arrFilesPath - array of the files to be zipped, arr文件路徑—被壓縮文件的排列組
e.g. Array("C:\*.exe", "C:\foldername\*.*")
注意:這個代碼需要在相同位置的ZIP.EXE效果。
正如這個文件
'---------------------------------------------------------
Sub CreateZipFile(ZipPath, arrFilesPath)
Const PKZIP_FILE_NAME="zip.exe"
Dim strCommand, objShell, objFSO
Dim x
首先檢查zip.exe文件里面的:
Set objFSO=Server.CreateObject("Scripting.FileSystemObject")
If Not(objFSO.FileExists(Server.MapPath(ZIP_FILE_NAME) )) Then
Set objFSO=Nothing
Err.Raise 20000, "Zip File Creator", "zip utility not found: "&Server.MapPath(ZIP_FILE_NAME)
End If
刪除當前的文件:
If objFSO.FileExists(ZipPath) Then
objFSO.DeleteFile(ZipPath)
End If
Set objFSO=Nothing
批量命令:
strCommand=Server.MapPath(ZIP_FILE_NAME)&" -add "&ZipPath&" "
For x=0 To UBound(arrFilesPath)
strCommand=strCommand&arrFilesPath(x)
If x < UBound(arrFilesPath) Then strCommand=strCommand&" "
Next
執(zhí)行:
Set objShell=Server.CreateObject("WScript.Shell")
objShell.Run strCommand, 0, True 'wait!
完成:
Set objShell=Nothing
End Sub
%>
now u can call your CreateZipFile() function
-checkZipFile.asp
< %
Call checkZipFile()
Sub checkZipFile()
創(chuàng)建zip和給出鏈接:
Call CreateZipFile(Server.MapPath("Testzip.zip"), Array(Server.MapPath("images")&"\*.*"))
Response.Write("click here download zip")
End Sub
%>
總結
以上是生活随笔為你收集整理的asp 可否压缩_怎样用ASP压缩文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 单片机实验:数据区传送程序
- 下一篇: mysql三表where查询_mysql