Answer the question
In order to leave comments, you need to log in
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
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
Run the program under the desired user
Or give the rights to the file to the current user.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question