Click here to Skip to main content
15,880,364 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi everyone,

I'm developing new software for Windows OS. My application need to create File in Computer LocalAppData and I can do it.

But that files should be cannot delete.

Or

What I need to do storage my application files?

I'm search to Embedded Resource File, but they cannot change after creation.

Please help me. It's very important issue for my app.
I think about to storage that files into Web but my application need to work Online or Offline. So, I need to storage files in user computer but how?

Thanks for answer. Have a good day...
Posted

You can't create files that can't be deleted or else viruses would be impossible to get rid of. If the user wants to delete those files then your app stops working (or you can re-create fresh copies), that's their decision.
 
Share this answer
 
Comments
Umut Comlekcioglu 16-Sep-15 9:03am    
But I need to keep them somewhere for re-create. Okay, I can't create "cannot delete file" but what is the other any solution? Where can I storage my files to somewhere User cannot reach?
Philippe Mori 16-Sep-15 11:14am    
User can delete any user file and can change permissions if necessary. What you have done is correct (put data in a somewhat hidden location) and should normally considered to be enough.

Having a copy on the web is also a good idea. It the user delete local copy then he will have to connect to get the data and offline mode won't be available.

For most application, it does not make sense to do more than that... You would have a lot of complex code to handle cases that will almost never happen.

You can make it somewhat harder to delete files but it won't be fullproof anyway and most user have no idea about local data anyway and those that know probably knows about security, hidden files, command line... So you won't gain much protection.
Sergey Alexandrovich Kryukov 16-Sep-15 11:49am    
For a record: there is the "absolute" way, not depending on permissions to prevent deletion by just using file system operations. But of course it does not mean that deletion of the file is impossible at all; and it hardly would be a very practical advice. Please see solution 1.
—SA
CPallini 16-Sep-15 11:51am    
True.
5.
One way to preserve some file from modifications or deletion, regardless of privileges, is to keep it permanently open in some process, for non-shared access (which is the default). To keep this state permanent, the code should also be executed permanently, which is possible if this process is the process of a Windows Service application, which also can be configured to auto-start on OS start. Of course, the user can also stop that service, but it's harder to do; not all users will be able to find out the way.

Of course, such course of action would be considered as abuse in most of the cases; I only gave you this idea, for completeness.

—SA
 
Share this answer
 
v3
Comments
CPallini 16-Sep-15 11:51am    
Wow, nice.
5.
Sergey Alexandrovich Kryukov 16-Sep-15 15:06pm    
Thank you, Carlo.
—SA
Umut Comlekcioglu 16-Sep-15 14:53pm    
Thanks for answer, I will try that way. I will storage them Online and also keep them in user computer and use them with service all time.
Sergey Alexandrovich Kryukov 16-Sep-15 15:07pm    
You are welcome. I would rather discourage so strong protection, but you are the one to make a final decision.
—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