Click here to Skip to main content
13,150,137 members (66,555 online)
Rate this:
Please Sign up or sign in to vote.
i want to create file or delete file in system dir like c:\windows\winsxs, when i call create file or delete
file on win7 or win8, the last error is 5, and i have administrator priviledge. how can i do? thank you.
Posted 2-Mar-13 4:19am
Sandeep Mewara 2-Mar-13 11:20am
the last error is 5
Not clear.
cd_JoeWang 3-Mar-13 5:25am
if you want to delete a file in vista/win7 system dir like c:\windows\winsxs\xxx.dat,
you must change the file's owner to administrator and add an allow ace with it.but i want to create or
delete file in system dir in my program by calling api like CreateFile or DeleteFile, but its return value
is 5, can not access. how can i do?
ThePhantomUpvoter 2-Mar-13 11:25am
You might have admin rights but that does not mean that whatever process you are using to create/delete files has admin rights.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Error code 5 means ERROR_ACCESS_DENIED as described here[^]. You need to add a manifest to your project that requests administrator privilege for the program, or use the "Run as administrator" link in Windows Explorer when starting it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170924.2 | Last Updated 2 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100