E
E
Evgeny Ivanov2022-04-11 20:59:19
C++ / C#
Evgeny Ivanov, 2022-04-11 20:59:19

How to set permissions on the Users folder?

Windows has a C:\Users folder, with user profiles (desktop, documents, etc.). For example, C:\Users\Ivan.
I need to get the size of this folder. How to get folder size in C# I know.

But I can't do it, because I don't have access to this folder.
By default, there is no access to someone else's folder, even the administrator (you can check - the size of such a folder is 0 bytes). You need to log in with local administrator rights, click on the folder and confirm access (dialog that this action requires administrator rights - ok). And then we will get access to the folder, see its size, etc., and the admin account with full access rights to the folder will appear in the security tab.

How to set permissions on the Users folder from C#?
I log in from under the local administrator i.e. I can do it by hand.

PS
Google. The code from the Internet was compiled, but causes security errors when executed.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oleg_ods, 2022-04-12
@oleg_ods

Create a manifest file for the application and run it as an administrator. Here is an example of how to do ittyts
Or here are a couple more options for solving the problem

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question