Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

goyalpk

macrumors newbie
Original poster
Aug 7, 2009
14
0
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
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.