peterhupp
asked on
Adventures with "OleControl Shell.Explorer.2" deleting the temporary files issue.
ok, got my OleControl Shell.Explorer.2 activex control to work and it shows pdfs and graphics files. But of course it needs a pdf file to exist so I create one. I am storing the documents in my mssql database as a varchar(max)
So, when my user wants to view the document, I create a temporary file and ole.navigate2 to the file.
But when I close the form, I want to delete the temporary file but of course it is in use.
So I navigate2 to "About:Blank" but I still have to wait .3 of a second before it is released.
Tried a DOEVENTS but no difference. I also have this after I navigate to the blank page:
but again, still need the delay. So any ideas, not sure if the inkey(.3) is going to be enough for all my client's slow machines and it seems like a patch and not a solution.
So, when my user wants to view the document, I create a temporary file and ole.navigate2 to the file.
But when I close the form, I want to delete the temporary file but of course it is in use.
So I navigate2 to "About:Blank" but I still have to wait .3 of a second before it is released.
inkey(.3)
delete file (tempfilename)
Tried a DOEVENTS but no difference. I also have this after I navigate to the blank page:
DO WHILE (this.Olecontrol1.Busy OR this.Olecontrol1.ReadyState <> 4)
DOEVENTS
ENDDO
but again, still need the delay. So any ideas, not sure if the inkey(.3) is going to be enough for all my client's slow machines and it seems like a patch and not a solution.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, your solution must work because the delay could be more than 5 seconds which is enough even for slow systems.
ASKER
I did try the try..delete file.... catch but sometimes it would make VFP crash.
ASKER
My solution worked the best and 100% of the time.