File reading in C/C++/C# without the rights to it, how to do?

Want to read a file to which the current user does not have rights. Doing for example:


FileStream fs = File.Open(fileName, FileMode.Open, FileAccess.Read);


Says access is denied. How to get around without reordering right?

Need an answer in C/C++ or C#, preferably on the sharp.
October 14th 19 at 11:01
3 answers
October 14th 19 at 11:03
Incorrect formulation of the question.
In short — no way.
If more detail:
1. the whole operation of any user program with file system through API functions of the operating system.
2. programming language (any) in this case, the only means of access to the data API funteam
3. file access is controlled by the operating system to the level of calling the API functions access the file.
4. so — no matter what language You are writing, if access is denied, then you won't get it.
The solutions to the problem:
and. to change access rights to the file
b. to start the process with sufficient rights to access the file
October 14th 19 at 11:05
To run the program under the correct user
Or give file privileges for the current user.
And how to give these rights from the program? It is unknown which file and under which user will be read. - Alex commented on October 14th 19 at 11:08
Customize user privileges or group in which he is, or let everyone read the file. - halle89 commented on October 14th 19 at 11:11
Depends on what OS.
And in Windows run the program with administrator rights.
If you do not have read rights, put rights using the Windows API or by calling the external program. - nicole.Parker commented on October 14th 19 at 11:14
October 14th 19 at 11:07
I do not understand the subject matter?
There is a file to which the current user has no rights. The program running under this user will have no rights. But it is necessary to make its reading, the question of how to do this? - Alex commented on October 14th 19 at 11:10
How it will read if she has no rights? Law created to restrict access. - halle89 commented on October 14th 19 at 11:13
So I ask how to get around. I understand why the right fit, but want to do the reading without them, like ran earlier decision in C++, but can't find it. - nicole.Parker commented on October 14th 19 at 11:16
So your question "How to hack the system of distribution of rights in the OS?" - Alex commented on October 14th 19 at 11:19
I was hoping that hack is not necessary, but if there is a solution, then it will fit. - halle89 commented on October 14th 19 at 11:22

Find more questions by tags C++C