什么是写保护,我怎样才能做到 [英] What Is Write Protection And How Can I Make It

查看:131
本文介绍了什么是写保护,我怎样才能做到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!我有一些问题什么是写保护

如果我想用我的程序设置文件夹制作它怎么能使它

或我无法制作它?

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?

推荐答案

写保护是一种(基于软件的)防止写入文件或文件夹的方法。 (USB记忆棒和存储卡不同,对它们的写保护通常是基于硬件的,需要进行物理更改才能启用或禁用。)您的安装程序可以将文件夹设置为只读 - 它位于文件类中:

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:
File.SetAttributes(folderPath, FileAttributes.ReadOnly);



但是...如果您的程序正在正确安装,现代操作系统不会让任何人在没有Admin访问权限的情况下写入ProgramFiles文件夹或子文件夹(管理员无论如何都可以从文件夹中删除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.


这篇关于什么是写保护,我怎样才能做到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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