Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi every one .
if i need to protect file from been deleted even with administrator rights like some window's files
so how can i do that in c# ???
thank to all
Posted
Comments
justinonday 21-Jan-11 3:50am    
create users give rights to users .
Also check every time deleting file whether login user have permission ...if condition false can't delete file .

Create a small service to keep it open at all times - set file share to ReadWrite:

http://msdn.microsoft.com/en-us/library/f20d7x6t.aspx[^]

http://msdn.microsoft.com/en-us/library/system.io.fileshare.aspx[^]

Not sure I would advice preventing admin from deleting a file though ...

Regards
Espen Harlinn
 
Share this answer
 
Comments
JF2015 21-Jan-11 5:18am    
Good idea.
Pravin Patil, Mumbai 21-Jan-11 5:32am    
hi espen, Can we use FileSystemWatcher to achieve this...?
Espen Harlinn 21-Jan-11 6:38am    
If you think about automatic "locking" of new files as they arrive/are created, then it might be used to choose which files to open.
Have a look at Windows File Protection:
http://en.wikipedia.org/wiki/Windows_File_Protection[^]
http://support.microsoft.com/kb/222193/en-us[^]
You could mimick that behaviour by a service in the background that, like Espen said, locks the file or just overwrites the file with a backup in case the file was deleted.
 
Share this answer
 
Comments
Espen Harlinn 21-Jan-11 6:39am    
Useful addition (5+)

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