restrict access to folder outside of program c#

自古美人都是妖i 提交于 2020-01-15 08:56:43

问题


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?


回答1:


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

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.



来源:https://stackoverflow.com/questions/27258159/restrict-access-to-folder-outside-of-program-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!