Tuesday, December 3, 2013

IOS call NSFileManager of copyItemAtPath: toPath: After copying the file can not be found: error

NSBundle * bundle = [NSBundle mainBundle];

NSString * mp4path = [bundle pathForResource: @ "thecopyfile" ofType: @ "mp4"];

NSString * filepath = [NSHomeDirectory () stringByAppendingPathComponent: @ "Caches / A"];

NSFileManager * fileManager = [NSFileManager defaultManager];

[FileManager copyItemAtPath: mp4path toPath: filepath error: & error];


Then I go to get all the files in the folder
Afor (NSString * filename in [fileManager enumeratorAtPath: filepath]) {
NSLog (@ "% @", filename);
}

But start copying the past but can not find the file that thecopyfile.mp4
Reply:
First copyItemAtPath inside filepath not a folder path. Must be a file path such as: a/temp.mp4.
Second, take a file folder below do not enumeratorAtPath, but contentsOfDirectoryAtPath, this path is the path to the file can not be written in the address.
Reply:
A folder you build it? Not established then need to create job
Reply:
Path problem on the first floor you can try and I feel that this issue
Reply:
cited a floor reply:
first copyItemAtPath inside filepath not a folder path. Must be a file path such as: a/temp.mp4.
Second, take a file folder below do not enumeratorAtPath, but contentsOfDirectoryAtPath, this path is the path to the file can not be written in the address.

Yes, that's the problem, thank you, as well, I use the following three ways to get something a file inside the same:
subpathsOfDirectoryAtPath:
contentsOfDirectoryAtPath:
enumeratorAtPath:
What difference does it make them

No comments:

Post a Comment