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.
 
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>
 
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.
 
Back
Top