Click here to Skip to main content
16,021,823 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to copy file in system drive using c# code...??
C#
DirectoryInfo Src = new DirectoryInfo(fileLocation);
DirectoryInfo Dest = new DirectoryInfo("c\\Windows\\System32\\ ' file to copy '");

that give the erroe
Access to the path 'C:\Windows\System32\'file to copy' in windows7

please give perfect solution..
Posted
Updated 14-Jul-12 0:01am
v2
Comments
Sergey Alexandrovich Kryukov 15-Jul-12 1:31am    
Why?
--SA

The perfect solution is: Don't try to copy files to system folders.

Seriously, it is a bad idea unless you are installing software, in which case the copy will be done for you if you use a deployment project. At any other time write access to these folder is seriously discouraged as it looks badly like virus or similar malicious activity.
 
Share this answer
 
'C:\Windows\System32' is operating system files location and needs additional privilege to copy any file via code over there.

Further, you should not copy any file from code to this location - it's not suggestible based on security concerns. You should try to copy your files to some other folder/location.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900