如何制作不可删除的文件夹 [英] How do I make a undeleteable folder

查看:83
本文介绍了如何制作不可删除的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hai我是一名刚接触编程的学生。我为我的项目用C#制作了一个软件系统。当我的软件启动时,它会自动在C:\ usersrs \ Example &\\AppData中创建一个文件夹。该文件夹包含一些重要的XML和文本文件,以便顺利运行该软件。如果该文件夹删除,该软件丢失了一些数据。所以我想让那个文件夹不可取。我的一个朋友告诉我,我可以通过制作Windows服务来实现这一目标。请帮忙。我希望不删除该文件夹



我尝试过:



我试图通过制作一个Windows服务来解决这个问题,但这不起作用

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

推荐答案

你不能,即使你可以,也不会保护你。如果可以的话,它确实如此,那么勒索软件对任何人都不会有问题,不是吗?但是如果磁盘被格式化,重新分区或者只是失败了怎么办?没有什么可以保存你的文件...



而不是试图保护文件的单个副本,煽动一个良好,可靠的备份系统,以确保如果有的话发生在文件 - 或计算机的任何其他部分 - 您可以快速,轻松地修复它,并且数据丢失最少。



我使用AOMEI Backupper:用于PC,笔记本电脑和服务器的数据备份和恢复软件 [ ^ ]有一个功能齐全的免费版本,可以保存整个星期。
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.


为什么你认为该文件夹可能会被删除?



魔术不会发生这种情况,但需要用户明确删除它。只是不在乎这样。应该允许用户在他自己的系统上做任何他想做的事情。如果他使系统或软件安装无法使用,那就是他的问题。
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.


你正以错误的方式接近它。您不能也不应该创建不可删除的文件夹。问题是您的应用程序需要处理文件/文件夹不能正常和正确地存在。



想想如果文件是数据库记录而不是文件系统你会怎么做 - 如果数据库是不可联系的,你会如何应对?



您可能会向用户显示错误并让他们选择尝试修复它。如果确实是成败,那么除了退出申请之外别无选择。



我会认真考虑如何/为什么要使用文件并让你的应用程序顺利运行(不确定这意味着什么),以及看看你是否可以删除这个要求。
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.


这篇关于如何制作不可删除的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆