NSFileManager's method copyItemAtPath fails while copying folder from USB to Desktop.

Discussion in 'Mac Programming' started by goyalpk, Dec 8, 2009.

  1. goyalpk macrumors newbie

    Aug 7, 2009
    Hi there,

    NSFileManager's method copyItemAtPath fails while copying folder from USB flash drive to Desktop.

    Error description is :

    Error Domain=NSPOSIXErrorDomain Code=1 UserInfo=0x10df30 "Operation could not be completed. Operation not permitted"

    Actually it creates folder on Desktop but not the files inside the source folder.

    Is it because of permission difference for file in USB flash drive and the file which needs to be created on Desktop?

    Code is:

    	NSString *srcPath = @"/Volumes/USB DRIVE/hello123";
    	NSString *destPath = @"/Users/Pankaj/Desktop/hello123";
    	NSFileManager *fm = [NSFileManager defaultManager];
    	BOOL isCopySuccess = NO;
    	NSError *err;
    	isCopySuccess = [fm copyItemAtPath:srcPath toPath:destPath error:&err];
    		NSLog(@"copy successfull");
    		NSLog(@"copy failed");
    		NSLog(@"%@", [err description]);
    Thanks so much in advance.
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    You're the only one who can say whether it's a permission problem or not. None of us out here can see what's on your flash drive, nor can we run your program using your Desktop folder.

    Revise your code to do more than just print the error's description. Get the error's userInfo dictionary and examine the keys and values for details on what caused the error.


Share This Page