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

    Joined:
    Aug 7, 2009
    #1
    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:

    Code:
    	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];
    	
    	if(isCopySuccess)
    		NSLog(@"copy successfull");
    	else
    	{
    		NSLog(@"copy failed");
    		NSLog(@"%@", [err description]);
    		
    		
    	}
    Thanks so much in advance.
    Pankaj
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
    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.

    http://developer.apple.com/mac/libr...e.html#//apple_ref/occ/instm/NSError/userInfo
     

Share This Page