Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai I am a student who is new to programming. I have made a software system in C# for my project. When my software starts it automatically creates a folder in C:\users\Example\AppData . That folder contains some important XML and Text files in order to run the software smoothly. If that folder deletes ,The software lost some data. So I want to make that folder undeletable. One of my friend told me that I can achieve this by making a windows services. Please help. I want that folder not be deleted

What I have tried:

I tried to make solve this problem by making a windows service but that won't work
Posted
Updated 6-Mar-18 2:29am
Comments
F-ES Sitecore 6-Mar-18 8:32am    
I have 1,000 apps installed on my machine and I could delete the folders or files of any of them, as is my right, and if I do they'll probably stop working which is my fault. What makes your app so special?

You can't, and even if you could, that wouldn't protect you. If you could, and it did, then Ransomware wouldn't be a problem to anyone, would it? But what if the disk is formatted, repartitioned, or just fails? Nothing would save your file then...

Instead of trying to protect a single copy of a file, instigate a good, solid backup system to ensure that if anything does happen to the file - or any other part of your computer - you can fix it quickly, easily, and with minimal data loss.

I use AOMEI Backupper: Data Backup and Restore Software for PC, Laptop and Server[^] which has a full-featured free version and can save your entire week.
 
Share this answer
 
Why do you think that the folder might get deleted?

This would not happen by magic but requires that a user deletes it explicitly. Just don't care about such. A user should be allowed to do whatever he wants on his own system. It is his problem if he makes the system or your software installation unusable.
 
Share this answer
 
You're approaching it in the wrong way. You can't and shouldn't create an un-deletable folder. The issue is that your app needs to handle the files / folder not being there gracefully and correctly.

Think about what you'd do if the "files" were database records rather than on the file system - how would you cope if the database was un-contactable?

You'd likely show an error to the user and give them the option of trying to fix it. If it really is a make or break, then you have no choice other than to exit your application.

I would give serious thought as to how / why the files are used and required to be present for your application to run smoothly (not sure what that implies), and see if you can remove the requirement.
 
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