Link to home
Start Free TrialLog in
Avatar of peterhupp
peterhuppFlag for Canada

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.

inkey(.3)
delete file (tempfilename)

Open in new window


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

Open in new window


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
Avatar of Pavel Celba
Pavel Celba
Flag of Czechia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, your solution must work because the delay could be more than 5 seconds which is enough even for slow systems.
Avatar of peterhupp

ASKER

I did try the try..delete file.... catch but sometimes it would make VFP crash.
My solution worked the best and 100% of the time.