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];
然后我再去获取A文件夹中的所有文件
for (NSString *filename in [fileManager enumeratorAtPath:filepath]) {
        NSLog(@"%@",filename);
    }但是却找不到开始复制过去的那个thecopyfile.mp4文件

解决方案 »

  1.   

    首先copyItemAtPath里面的filepath不能是个文件夹路径。必须是个文件路径如:a/temp.mp4。
    其次取a文件夹下面的文件不用enumeratorAtPath,而是contentsOfDirectoryAtPath,这个path才是路径,不能写成了文件的地址。
      

  2.   

    是的,就是这个问题,谢谢,还有,我用下面三种方式去a里面的文件得到的东西都一样:
    subpathsOfDirectoryAtPath:
    contentsOfDirectoryAtPath:
    enumeratorAtPath:
    他们有什么区别呢