Reputation: 11
Directory.Move("source","Des")
This code throws the following exception:
System.UnauthorizedAccessException: Access to the path is denied. ---> System.IO.IOException: Operation not permitted
Upvotes: 1
Views: 1051
Reputation: 599
Run the application as a user who has access to the directory (like administrator or Windows Service), Or in case you just want to know if the application is running well give access to the user or "everyone" to the directory.
you can give access to the user via CMD
(run as administrator)
C:\>icacls "D:\test" /grant everyone:(OI)(CI)F /T
According do MS documentation:
F
= Full Control
CI
= Container Inherit - This flag indicates that subordinate containers will inherit this ACE.
OI
= Object Inherit - This flag indicates that subordinate files will inherit the ACE.
/T
= Apply recursively to existing files and sub-folders. (OI and CI only apply to new files and sub-folders).
For complete documentation, you may run "icacls" with no arguments or see the Microsoft documentation here and here
check this answer as well on giving permissions: https://stackoverflow.com/a/8311008/3563665
Upvotes: 2