Delete a temporary file created in VB from the same program.

OK, here's my problem...  I am creating some temp files from my program.  After I convert them over to a format I want, I would like to delete them, but no matter what I do, file scripting object, kill, shell to dos and deltree, the files are undeletable until I exit my program.  I have tried everything I can think of but am probably missing something simple or it can't be done???  I need to delete the files from my program shortly after they are created.  I have tried unloading the form even and deleting them from a Shutdown routine and still no go...I cannot even delete them from Filemanager until the program ends.  Any ideas?
LVL 6
sharmonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caraf_gCommented:
Make sure you close the files after you're finished creating them.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
caraf_gCommented:
(or using them or anything)

In other words, somewhere in your program you open the file but you forget to close it after you're done with it.
0
deightonprogCommented:
You can make a separate program to delete them which pauses for a second or two then call it from you main app

shell "deleteprog"

unload ..etc
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

sharmonAuthor Commented:
I will try your ideas and get back to you tomorrow thanks...

Shannon
0
chaos_59Commented:
You need to close the files. You can't delete the files, or in some cases open the files with another application until your program closes them.
0
caraf_gCommented:
yes, I already said that.
0
sharmonAuthor Commented:
Ok, sorry it took me a couple days, I had to finish up some work on another program.  Caraf_G, let me point this out and maybe you might have a different answer before I reject this one...ok.  I know that if I open a file and write to it myself that I have to close it before I delete it...that's pretty basic.  But I am not directly creating the file.  I am using a third party ocx to create the file.  And no matter what I do, I cannot delete the file until I have exited my program.  So is there a way around that at all.  A "shelled program" will not delete it as I cannot even do it manually.  Is there a way to force the os to close the file regardless of my app?  If it's harder I'll increase the points...if it can't be done, I'll just give them to Caraf....thanks alot for any recommendations....
0
caraf_gCommented:
Aha, in that case it seems to me that your 3rd party OCX is not closing the file.

There is only one solution to this, and it's rather naff.

Create a tiny .exe containing the 3rd party ocx control. Shell it synchronously (plenty of threads in this forum explaining how that works). When the .exe finishes, the file automatically gets closed, thereby fixing the problem caused by the OCX that does NOT close the file.

Any data that needs to be passed to the OCX can be passed via command line arguments. Again, there are quite a few threads in this forum explaining how to do that in case you don't know.

Use oldlook.experts-exchange.com for a more useful search engine.

Good luck!

Pino
0
sharmonAuthor Commented:
Thanks Caraf, I know that will work, I just didn't think about it....thanks again, take care.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.