c# - 如何限制文件夹/文件只能访问一个程序?

标签 c# winforms file security directory

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

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

这可能吗?我研究了 MSDN 的文件安全结构,在研究它时,我看到人们提示说,如果您将文件限制为用户,那么该人就可以覆盖权限并使其可编辑。

另外,我考虑过这实际上是如何工作的,考虑到本质上我想要一个只编辑文件的进程,并且如果它随着时间的推移打开和关闭,该进程可能有不同的进程 ID,这似乎很难。

有什么想法吗?

最佳答案

即使这不能满足您的所有要求,您也可以尝试 IsolatedStorage (System.IO.IsolatedStorage 命名空间)。

How to write and read file in IsolatedStorage

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

关于c# - 如何限制文件夹/文件只能访问一个程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20010372/

相关文章:

linux - 如何在 linux 文件中创建空行

ASP.NET 请求 - 我可以从客户端创建的动态控件获取发布的文件吗?

c# - 如何获得对模型绑定(bind)的控制?

c# - 在哪里可以找到免费、易于实现的 .NET 拼写检查组件?

C# 在运行时更改类方法

c# - 获取应用程序路径

c# - 如何在类属性中分配值类

c# - 如何从WebBrowser控件中提取XML?

c# - 如何知道一个类的属性类型是否是自定义的

php - PHP 中的 UPLOAD_ERR_EXTENSION (#8)?