限制对程序外的文件夹的访问c# [英] restrict access to folder outside of program c#

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

问题描述

我开发一个C#应用程序,将数据保存到一个文件夹。我想要的文件夹在文件浏览器仅限于所有用户,只有通过编程应用程序访问。因此,应用程序可以完全访问该文件夹,但不能透过窗户直接访问。我怎样才能做到这一点?

I am developing a C# application which saves data to a folder. I want the folder to be restricted to all users in file explorer and only accessible programmatically through the application. So the application has full access to the folder, but it cannot be accessed directly through windows. How can I accomplish this?

推荐答案

在Windows的权限是每个用户,并且没有每个应用程序的权限。

In Windows permissions are per-user, and there are no "per-application" permissions.

因此,为了能够阻止谁访问该文件夹运行应用程序当前用户你需要运行读冒充其他文件夹中/ wirites数据代码帐户。比你可以设置权限是只是用户访问。

So to be able to prevent current user who runs the application from accessing the folder you'll need to run code that read/wirites the data in the folder to impersonate another account. Than you'll be able to set permission to be accessible to just that user.

请注意,如果用户拥有管理员权限,例如用户仍然可以通过覆盖可以访问该文件夹您的安全设置。

Note that if user have admin privileges such user still can get access to the folder by overwriting your security settings.

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

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