Denied permission when creating folder

Asked

Viewed 71 times

-2

I was creating an application that needs to create a folder in System32 or in the windows folder itself, only it needs permission and error:'O acesso ao caminho 'C:\Windows\pasta' foi negado.' Does anyone know how I can create without permission?

string diretorio = @"C:\Windows\pasta";
        if (!Directory.Exists(diretorio))
        {
            Directory.CreateDirectory(diretorio);
        }

1 answer

2


You need to access your program as an Administrator (right-click, Run as Administrator), or if you are thrashing have to do the same to open Visual Studio.

If you want to ensure that your application will always run as an Administrator, add a file manifest in your project and fills the attribute level of the element requestedExecutionLevel with the value requireAdministrator:

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.