如何仅限制对程序的文件夹/文件访问? [英] How to limit folder/file access to a program only?

查看:80
本文介绍了如何仅限制对程序的文件夹/文件访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我正在创建一个c#winforms应用程序.

Okay, so I am creating a c# winforms application.

我想从二进制数据文件写入/读取.但是,我想将该文件放在某个位置的文件夹中,并且我不希望任何人都可以删除或编辑该文件.我只希望使用该文件的程序能够访问它.

I want to write/read from binary data file. But, I want to put that file in a folder somewhere and I do not want anyone to be able to delete or edit the file. I only want the program that uses the file to be able to access it.

这可能吗?我研究了MSDN的文件安全性结构,并在研究它时发现有人抱怨说,如果将文件限制为用户,则该人可以覆盖特权并使其可编辑.

Is this possible? I looked into MSDN's structure on file security and as I researched it I saw people complain that if you limit the file to a user then that person can just override the privileges and make it editable.

另外,我考虑了本质上的考虑,我只想一个过程来编辑文件,并且如果随着时间的推移打开和关闭该过程ID可能会有所不同,那么这很困难.

Also, I thought about how this would actually work considering in essence I would like a process to edit the file only and that process could have varying process ID's if it is opened and closed over time, seems tough.

有什么想法吗?

推荐答案

即使这不能满足您的所有要求,您也可以尝试

Even though this will not satisfy all your requirements you can try IsolatedStorage (System.IO.IsolatedStorage Namespace).

如何在隔离存储

System.IO.IsolatedStorage命名空间包含的类型允许创建和使用隔离的商店.通过这些商店,您可以阅读并写入不太受信任的代码无法访问的数据,并防止暴露敏感信息,这些信息可以保存在文件系统.数据存储在由当前用户以及代码所在的程序集.此外,可以按域隔离数据.漫游配置文件可以是与隔离存储结合使用,因此隔离存储将与用户的个人资料一起旅行.IsolatedStorageScope枚举表示不同类型的隔离.有关更多信息何时使用隔离存储

The System.IO.IsolatedStorage namespace contains types that allow the creation and use of isolated stores. With these stores, you can read and write data that less trusted code cannot access and prevent the exposure of sensitive information that can be saved elsewhere on the file system. Data is stored in compartments that are isolated by the current user and by the assembly in which the code exists. Additionally, data can be isolated by domain. Roaming profiles can be used in conjunction with isolated storage so isolated stores will travel with the user's profile. The IsolatedStorageScope enumeration indicates different types of isolation. For more information about when to use isolated storage

这篇关于如何仅限制对程序的文件夹/文件访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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