Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to make a file as access denied. Example: I have a file name called "testing.txt" inside C Drive (@"C:\\Test\testing.txt"). Now I want to make this file as Access Denied, it means no one should not able to access it. By clicking (Right button --> Properties --> Securities) I can make it access denied, but here my question is how can I make it access denied through coding.
Posted
Comments
Kornfeld Eliyahu Peter 16-Sep-14 4:11am    
If you want the file accessible by no-one - delete it!!! :-)
Aboobakkar Siddeq D U 16-Sep-14 4:12am    
No I don't want to delete, that file should be there, and by clicking on another button that file should be accessible.
Kornfeld Eliyahu Peter 16-Sep-14 4:26am    
It was a joke!
There is a FileSecurity class in .NET (http://msdn.microsoft.com/en-us/library/system.security.accesscontrol.filesecurity(v=vs.110).aspx). You may use it to remove all ACL entries except yours...

1 solution

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