asp-classic - 在经典 asp 中解压缩文件

标签 asp-classic vbscript unzip fso

我正在尝试使用 unzip/zip 类。我需要在上传后解压 zip 文件。我修改了“ sleep ”函数来检查每个 intSeconds 值的“ Controller ”函数,并添加了“ Controller ”函数来检查目标文件夹上的文件计数。您可以在下面看到代码部分。

使用此功能成功解压 zip 文件,但页面进度永远不会结束。使用此功能后我需要重新启动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

%>

最佳答案

这行就是问题所在

if dteEnd=Now() then

只有当 dteEnd 与 Now() 完全一样(精确到毫秒)时,它才能进入 Controller 部分并前往导出 do,但它不会并进入递归循环(回到 sleep 函数)

试试这个:

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

关于asp-classic - 在经典 asp 中解压缩文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16200691/

相关文章:

c# - 在 .net 中以编程方式解压缩文件

html - 无法将单选按钮值发送到 SQL

vbscript - 经典 ASP IIS 6.0 下 VBScript 中 Server.CreateObject 上的 HTTP 状态 443

batch-file - 如何通过 7Zip 使用批处理脚本解压缩受密码保护的文件?

javascript - 我的网站如何让访问者登录到第三方网站?

windows - 使用 Windows shell 脚本自动打开文件

R:可能截断 >= 4GB 文件

asp-classic - 经典 ASP 中的 500 Vs 500.100 错误

css - 使用 VBSCRIPT,经典的 ASP 动态设置表单样式

database - 服务器正在生成页面时显示加载屏幕