"This file is being used by another process", can I know the name of process?
-
My winform application(C#) needs to delete a file, I have set all references to that file in my code with
null
and then I useFile.Delete
..Catching exception sometimes shows - "this file is being used by another process".. Is there any API by which we can know who has locked the file handles and if thers any sharing violation...so my application can show a cute message saying :((XYZ file is being used application :((APP Do tell me if I need to configure any CASPOL settings.. -
My winform application(C#) needs to delete a file, I have set all references to that file in my code with
null
and then I useFile.Delete
..Catching exception sometimes shows - "this file is being used by another process".. Is there any API by which we can know who has locked the file handles and if thers any sharing violation...so my application can show a cute message saying :((XYZ file is being used application :((APP Do tell me if I need to configure any CASPOL settings..abcxyz82 wrote: I have set all references to that file in my code with null Did you actually
Close()
the file before you set the reference tonull
?
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
abcxyz82 wrote: I have set all references to that file in my code with null Did you actually
Close()
the file before you set the reference tonull
?
My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
-
Actually my application loads image from the file name in some controls and saves image in business object...and I remove trace of that image file from all placess(removing from control,setting null in business object)..etc.. REgards MaulikCE
Colin's question still stands. Did you close the file before you set the object you used to
null
. If not, and even if you dropped your reference to the stream object, the underlying unmanaged file handle is not released until you either call theClose()
method or the Garbage Collector gets around to calling the objects.Dispose()
method. Until one of those two things happens, the underlying file handle will remain OPEN and, hence, sitll in use by another application, specifically, yours. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome