Help with deleting a file.

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.
 
M

Michael Nemtsev

Hello davem,

how this relates to the ASP.NET?

To perform you task gracefully, you need to get the filehandler and enumerate
all processes, comparing the filehandler belonging to the current process'
filehandlers. And when the desired process will be found - kill process.
This task relates to diving to the unmanaged world, even deeper, using undocumented
NT functions (goole to find the sample I provided how to do this)


---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

d> My mobile application needs to be able to delete the database on the
d> mobile device. However if another application (such as Query
d> Analyzer) had previously been connected to it, I receive an error
d> telling me the file cannot be deleted due to a sharing violation.
d> Then I need to go into Running Programs and manually stop the Query
d> Analyzer to delete the database.
d>
d> I there a way to either unconditionally delete the database file or
d> release all resources to that so that the file may be deleted
d> programmatically?
d>
d> Ant suggestions are greatly appreciated.
d>
d> Thanks,
d>
d> Dave M.
d>
 
D

davem

Michael,

My apologies for inadvertently posting to the wrong group not once but twice
(been that kind of day).
But I do appreciate you taking the time to reply.

Thanks,

Dave M.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top