Link to home
Start Free TrialLog in
Avatar of rpatna
rpatna

asked on

SHFileOperation problem

Hi,
I'm usingh SHFileOperation function to copy and remove folder.
this function Returns zero if successful, or nonzero otherwise.

if it returns nonzero, then how I know  that what are the actual problem.

I'm getting nonzero returns value when their is no space in harddisk. in this condition I want to display the message "No disk space"

so, how I know the real problem on nonzero returns.
ASKER CERTIFIED SOLUTION
Avatar of bkfirebird
bkfirebird

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of akalmani
akalmani

Why not use CFile which throws an exception in case of an error and you can handle accordingly. Using SHFileOperation() you must validate all the inputs before carrying out the operation.
Avatar of rpatna

ASKER

how to use CFile to copy entire folder and delete entire folder?
Oops i am sorry I did not read MSDN clearly though..CFile works only for files. bkfirebird is right. Use GetLastError() to find if any error has occurred. Also make a check for fAnyOperationsAborted flag after the operation. As such the function just returns boolean value. Its a known issue of SHFileOperation() API.

Best way to do is write a recursive function which does file copy recursively.
The asker did not get back even though, gave him some hints/solutions
Avatar of rpatna

ASKER

no comment is my solution. so admin can close this.