Help with deleting a file

  • Thread starter Thread starter davem
  • Start date Start date
D

davem

My mobile application needs to be able to delete the database on the
mobile device. However if another application (such as Query
Analyzer) had previously been connected to it, I receive an error telling
me the file cannot be deleted due to a sharing violation. Then I need to
go into Running Programs and manually stop the Query Analyzer to delete
the database.

I there a way to either unconditionally delete the database file or release
all resources to that so that the file may be deleted programmatically?

Ant suggestions are greatly appreciated.

Thanks,

Dave M.
 
Let's say that you could somehow forcibly delete the file. Think that the
query analyzer would crash? That doesn't seem like a very professional
thing to have your device do to your customer. Maybe you could, instead, do
what happens when you Stop that program, except from your own program. I
think that's been covered here before. Take a look in the archives using
GoogleGroups:

http://groups.google.com/group/micr...ork/topics?hl=en&lr=lang_en&ie=UTF-8&oe=UTF-8

Basically, what you might try is, if you know the name of the main window of
that program, you can use FindWindow() to get a handle to the window, send
it a WM_CLOSE message and, if that doesn't exit the program, use
ToolHelp.dll to terminate the process.

Paul T.
 
Back
Top