user3185333
user3185333

Reputation: 47

Access denied while accessing files in c:\Programdata in Windows 10

I am designing an command line application for Windows 10 that require to replace some files in c:\programdata folder. But when I use File.Copy or File.Move, it throws an exception as:

Access to the path 'C:\ProgramData\***' is denied.

I have added app.manifest with requireAdministrator but it doesn't work. Am I missing something?

Upvotes: 1

Views: 11080

Answers (2)

EfiBN
EfiBN

Reputation: 408

Try to check the user identity the actually runs the process/execute file.

This user should by "System" to have permissions to Move/Copy files on the Disk.

In debug mode you can always check the Task Manager => Processes and see the User Name for your process.

Upvotes: 1

M_Idrees
M_Idrees

Reputation: 2182

Make sure you have permissions on that folder. e.g. Right Click on folder > Properties > go to Security tab, and check if you have permissions. Also try your application by right click and 'Run as Administrator'.

Upvotes: 5

Related Questions