Reputation: 764
I'm trying to use an unzip/zip class. I need to unzip a zip file after upload. i modified "sleep" function to check "controller" function per intSeconds value and added "controller" function to check file count on target folder. You can see a code part below.
zip file is successfully unzipped with this functions but page progress never ending. i need to restart iis after to use this function.
Original code on : 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
%>
Upvotes: 2
Views: 2874
Reputation: 7372
I haven't tried it, but given that I found this this Stack Overflow question and github solution in the same search result. I thought this might be a good shot as a solution to your problem.
https://github.com/rcdmk/aspZip
Upvotes: 1
Reputation: 2952
This line is the problem
if dteEnd=Now() then
Only if dteEnd is exactly the same as Now() (to the millisecond) will it be able to step into the controller section and head towards the exit do, it doesn't and goes into a recursive loop (back into the sleep function)
Try this instead:
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
Upvotes: 1