Click here to Skip to main content
15,903,201 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Windows will prevent you from deleting a file that's in use by a running program.


how can i implement in my application for a file.
Posted

My suggestion may be more of a hack-solution than a good one, but I would possibly just open a handle to the file, thus marking it in use from the OS perspective, and not release the handle until the application exits. If you are trying to make the file undeletable in the OS at any time, even when your program is not running, I'm not sure it can be done.
 
Share this answer
 
Comments
subhash04573 3-Dec-10 8:23am    
HOw to do it?
just open a handle to the file, thus marking it in use from the OS perspective, and not release the handle until the application exits.
fjdiewornncalwe 3-Dec-10 8:32am    
Exactly. From the perspective of the OS, the file is "in use" as long as you have an active handle to the file in your application using the File.Open or something like that.
See 'Example added (ManfredRBihy):' section in John Simmons answer here[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900