Mothra Posted July 27, 2004 Posted July 27, 2004 Is there a way to "force" a file to be deleted even if it is "...being used by another process."? I have tried both of these methods: File.Delete(myFile) 'and Kill(myFile) I am closing all file and/or memory streams that opened the file origionally but it does not seem to have any effect on my ability to delete it. Am I missing something?? Quote Being smarter than you look is always better than looking smarter than you are.
bri189a Posted July 27, 2004 Posted July 27, 2004 If it's being used by another process the process has to be aborted first. There is no way around it. What is the file? Quote
Mothra Posted July 27, 2004 Author Posted July 27, 2004 It's just an xml file. Once I'm done processing the information in it, I don't need it anymore so I'd like to discard it altogether. Is there a way to find out what process has it and then abort that process? p.s. I like your avitar! ;) Quote Being smarter than you look is always better than looking smarter than you are.
Administrators PlausiblyDamp Posted July 27, 2004 Administrators Posted July 27, 2004 If you have a look on http://www.sysinternals.com they have a utility called Process Explorer - that will be able to tell you what has the file locked. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
bri189a Posted July 27, 2004 Posted July 27, 2004 yeah this avatar has really gotton around; not sure where it started...had it forever now as I'm sure you have too... Quote
Mothra Posted July 28, 2004 Author Posted July 28, 2004 Just noticed something strange about it as well, I will normally have multiple files in the directory to be deleted but, if there is only one file in the directory, it works just fine. Once there is a second file there, the first file causes an exception...very strange. I'll check out that process explorer though, thanks! Quote Being smarter than you look is always better than looking smarter than you are.
Mothra Posted July 28, 2004 Author Posted July 28, 2004 Just wanted to let y'all know that I resolved the issue. I used the Process Explorer and found what was using the file. Thanks all! Quote Being smarter than you look is always better than looking smarter than you are.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.