How to lock a file in .net so that only my application can access it?

I read requests regarding file locking, but either they refer to a problem with multiple files, or to something else. The answer to this will be blocked by the file using FileStream.Lock, using FileShare.None with File.Open, etc., but the lock says 100 files are not good programming practice, also in these scenarios the lock will be released if my application closes / a glitch that I don't want either, i.e. I want the lock to persist, and only my application can open it to others.

In msdn, I found the System.Security, System.Security.AccessControl namespaces, I believe this can help. Also this article will shed some light on what I want.

EDIT ::

Mannnnn ... someone referred to the "this" link that I provided.

Ok ... In short, I want something that makes PC security software. It rings the bell ... did anyone use it ????

Thank.

+3
source share
6 answers

It is simply not possible. A user with sufficient authority can always change security settings and run a program to access your file. So, work on the assumption that you cannot stop this and focus on what the program or user can do with the data in the file.

Encrypt it.

+2
source

, , , ACL. , , , , , , .

, , , " ", , , , , , .

, , , . - , .

? , .

+1

. , " ".

+1

_. , .

MSDN IsolatedStorage. . applicationData ( )

0

( "" ), .

, , , . , , , ( SolFS ).

, . , 100% .

0

I think the thing you want is only possible using the file system mini-filter driver. since many other applications provide this functionality using a driver, such as a universal screen where you can make the process trusted, so only a trusted process can access this file / folder to another application, for example, folder protection, which also provides this type of permission per file / folder.

0
source

Source: https://habr.com/ru/post/1788943/


All Articles