O
O
Ogoun Er2010-11-07 14:55:44
C++ / C#
Ogoun Er, 2010-11-07 14:55:44

Reading a file in C/C++/C# without rights to it, how to do it?

I want to read a file to which the current user has no rights. I do for example:
FileStream fs = File.Open(fileName, FileMode.Open, FileAccess.Read);
Writes access denied. How to get around without reassigning rights?
Need an answer in C/C++ or C#, preferably in sharp.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
SparF, 2010-11-07
@SparF

Incorrect question.
In short, no way.
In more detail:
1. All work of any user program with the file system is carried out through the API function of the operating system.
2. the programming language (any) in this case is only a means of accessing the program to these API functions
3. access to the file is controlled by the operating system itself already at the level of calling the API function for obtaining access to the file.
4. thus - in whatever language you write, if access is denied, then you will not receive it.
Solutions to the problem:
a. change file permissions
b. start a process with rights sufficient to access the file

N
NanoDragon, 2010-11-07
@NanoDragon

Run the program under the desired user
Or give the rights to the file to the current user.

U
undead_ekb, 2010-11-07
@undead_ekb

Did not understand the essence of the question?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question