在经典asp中解压缩文件

在经典asp中解压缩文件

问题描述:

我正尝试使用unzip/zip类。上传后我需要解压zip文件。我修改了“睡眠”函数来检查每个intSeconds值的“控制器”函数,并添加了“控制器”函数来检查目标文件夹上的文件数量。您可以在下面看到代码部分。在经典asp中解压缩文件

压缩文件成功解压缩使用此功能,但页面进度永不结束。使用此功能后,我需要重新启动iis。

原始代码上:Class CompressedFolder

<% 
    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 

%>

+0

您能够通过代码调试步骤?您报告的无限执行只有在'controller'总是返回false时才可能(即总是调用递归) – 2013-04-25 04:00:49

此行是问题

if dteEnd=Now() then 

只有dteEnd是正是一样NOW()(至毫秒)它将能够进入控制器部分并朝向出口do,它不会进入递归循环(回到t他睡眠功能)

试试这个:

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 

我还没有尝试过,但因为我发现在相同的搜索结果这个这个堆栈溢出问题,github上的解决方案。我认为这可能是一个很好的解决方案。

https://github.com/rcdmk/aspZip