when I use MoveFileEx to move files in C drive, but I am getting the ERROR that ACCESS DENIED. Any solutions
int i ;
DWORD dw ;
String^ Source = "C:\\Folder\\Program\\test.exe" ;
String^ Destination = "C:\\test.exe"; // move to program Files Folder
pin_ptr<const wchar_t> WSource = PtrToStringChars(Source);
pin_ptr<const wchar_t> WDestination = PtrToStringChars(Destination);
i = MoveFileEx( WSource, WDestination ,MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED ) ;
dw = GetLastError() ;
You need to make sure that the user account your process runs under has read access to the file being moved and write access to where it’s being written to. And that the file being moved isn’t locked by another process and that there isn’t a file with the same name in the destination directory that’s locked by another process.
Try moving the same file manually in Windows Explorer and see what errors you get, when you can do that without problems your app will probably work too (assuming they’re running under the same account).