【发布时间】:2023-06-19 00:13:01
【问题描述】:
我正在尝试使用 unzip/zip 类。上传后我需要解压缩一个 zip 文件。我修改了“睡眠”功能来检查每个 intSeconds 值的“控制器”功能,并添加了“控制器”功能来检查目标文件夹上的文件计数。您可以在下面看到代码部分。
使用此功能成功解压缩zip文件,但页面进度永无止境。我需要重启iis才能使用这个功能。
<%
Set objShell = CreateObject("Shell.Application")
Set objFso = CreateObject("Scripting.FileSystemObject")
Function ExtractAll(strZipFile, strFolder)
If Not objFso.FolderExists(strFolder) Then objFso.CreateFolder(strFolder)
intCount = objShell.NameSpace(strFolder).Items.Count
Set colItems = objShell.NameSpace(strZipFile).Items
objShell.NameSpace(strFolder).CopyHere colItems, 8
Sleep 5000,strFolder,intCount + colItems.Count
End Function
function controller(path,filesCountMust)
dim stat:stat=False
set fold = objFso.getFolder(path)
set files = fold.files
if filesCountMust=files.count then
stat=True
end if
set files = nothing
set fold = nothing
controller=stat
end function
Sub Sleep(intSeconds,path,filesCountMust)
dblSeconds = intSeconds / 1000
If dblSeconds < 1 Then dblSeconds = 1
dteStart = Now()
dteEnd = DateAdd("s", dblSeconds, dteStart)
do While dteEnd>=Now()
if dteEnd=Now() then
if controller(path,filesCountMust)=true then
exit do
else
Sleep intSeconds,path,filesCountMust
end if
end if
loop
End Sub
Set objShell = Nothing
Set objFso = Nothing
%>
【问题讨论】:
-
你能在调试器中单步执行代码吗?只有当
controller始终返回 false(即始终调用递归)时,您报告的无限执行才是可能的
标签: asp-classic vbscript unzip fso