Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
hello
I have writen a program that use a file and I want to limit access to this file as another program or user can not change or delete this file.

Thank
Posted
Updated 1-Mar-11 9:49am
v2
Comments
Albin Abel 1-Mar-11 15:06pm    
I think you may use Isolated storage

If you want to protect your file just during your run-time, you can simply keep it open with exclusive access to it (which is by default). You can close your stream at the very end of run-time.

—SA
 
Share this answer
 
Comments
Albin Abel 1-Mar-11 15:36pm    
Good thinking. My 5
Sergey Alexandrovich Kryukov 1-Mar-11 15:52pm    
Thank you.
--SA
 
Share this answer
 
v3
Comments
Sergey Alexandrovich Kryukov 1-Mar-11 15:30pm    
This is a sound idea, my 5 (do you mind I edited your Answer?)
--SA
Sergey Alexandrovich Kryukov 1-Mar-11 15:33pm    
May be something more simple would suffice? Please see my Answer.
--SA
Albin Abel 1-Mar-11 15:35pm    
Thanks SAKryukov. You can edit the answer. No problems
Yusuf 1-Mar-11 15:37pm    
Good Answer
Albin Abel 1-Mar-11 15:42pm    
Thanks Yusuf
Basically, you can't.
You can hide it, and make it read only, and even system (if you have the permissions) but anything you can do, someone else can do too. If they couldn't, you couldn't change or delete it either.

Better solution: encrypt the file content so it can't be modified, make it read only if you must, and hope.
 
Share this answer
 
Comments
Albin Abel 1-Mar-11 15:14pm    
Encryption is a good point too. My 5
Sergey Alexandrovich Kryukov 1-Mar-11 15:32pm    
Basically you're right, but... may be OP needs something much more simple -- see my Answer.
--SA

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