ios - Objective-c: Copying a Directory to another -


I'm trying to copy an entire folder contents to another folder by using Object-c on iOS.

I have tried to create and copy the directory with a UIAlertView to check the error using NSFileManager:

  [[ NSFileManager defaultManager] createDirectoryAtPath: @ "/ tmp / destination / directory /" side-by-side directories: yes property: zero error: zero]; NSError * copyError = Zero; If ([[NSFileManager defaultManager] copyItemAtPath: @ "/ source / directory / toPath: @" / tmp / destination / directory / "Error: & amp; copyError]) {UIAlertView * alertView = [[UIAlertView alloc] initWithTitle: @ "Watusi" Message: [copyError Description] Representative: Cancel zeroTantel: @ "OK" other buttontitles: zero]; [warning view];}  

The code is not working and I'm getting the following error:

  error domain = NSCocoaErrorDomainCode = 516 "operation can not be completed. (Cocoas error 516.) "userInfo = 0x1666db90 {NSSourceFilePathErrorKey = / source / directory /, NSUserStringVariant = (copy), NSFilePath = / source / directory /, NSDestionationFilePath = / tmp / destination / directory /, NSUnderlyingError = 0x14697b30" could complete operation The file will not exist "}  

Actually the directory is being created but the files are not being copied

I check every question related to my problem But not able to fix it.

Make the destination directory and then copy all the files inside the source directory and copy them to the destination .

The subdirectory will make some things complicated. Your code should be recursive .

UDIT:

Here is the code sample. Please note, This subdirectory does not handle.

  NSString * sourcePath = @ "..."; NSString * destPath = @ "..."; NSFileManager * FM = [NSFileManager defaultManager]; [FM createDirectoryAtPath: destPath withIntermediateDirectories: Yes Properties: Zero Error: Zero]; NSArray * sourceFiles = [FM contentsOfDirectoryAtPath: sourcepath error: NULL]; NSError * copyError = nil; BOOL directory; ([String string * currentFile in sourceFiles] {If ([FM fileexists atpath: current file headline: & amp; isDirectory] & amp; amp;! IBILATAPT: [SourcePath stringbappingpacecontent: current file] Tupath: [Pathpath stringbappingpathConponant: currentfile] Error: amp; copy]} {Uaiaelrtwu * alerts weave = [[Uaielartwu light] Int Vithtaitl: @ "Votrsi" message: [CopyError details] representatives: zero cancellation Krenttntitl: @ "Alright The "other Btntaitls: zero] [Warning visual image]; In addition, instead of the error after each failed copy operation, I have a temporary array will make, where I failed to copy that'll add the file names and then Show user. Loop 


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -