Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi every one! I have some question "What is the write protection"
and if I want to make it with my program setup folder how can I make it
or i can't make it?
Posted
Comments
Member 11277077 2-Apr-15 10:57am    
Please and Thank you for you answer
Sergey Alexandrovich Kryukov 2-Apr-15 11:06am    
If you don't know what is it, you cannot possibly "want" it.
The question makes no sense at all. "Write protection" means protecting something from being modified. Everything else depends on: what do you want to protect and why? Don't even bother answering...
—SA
PIEBALDconsult 2-Apr-15 11:33am    
Doesn't matter; the user's wants always outweigh the developer's wants.

1 solution

Write protection is a (software based) way to prevent writes to a file, or folder. (USB sticks and memory cards are different, the write protect on those is normally hardware based and requires a physical change to enable or disable.) Your setup program can set a folder to read only - it's in the File class:
C#
File.SetAttributes(folderPath, FileAttributes.ReadOnly);

But...if your program is being installed properly anyway, modern OS's won't let anyone write to the "ProgramFiles" folder or subfolders without Admin access (and an Admin can remove ReadOnly from a folder anyway).

So probably the best thing to do is just let your setup program put the app in the "normal" place, and just create a folder below the app to store your read-only data. Then there is nothing else you should really need to do.
 
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