How to copy multiple files from resource folder to document directory?
I want to copy multiple files(with .vot files) from my app to document directory path.
Here I am going to add some file开发者_开发知识库s in my project and this files need to be copied in document directory folder.
For Example ,
I have files like
1) One.vot
2) Two.vot
How do I copy this .vot files in document directory ?
NSString* directoryPath = [NSString stringWithFormat: @"%@/Files", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex: 0]];
[[NSFileManager defaultManager] createDirectoryAtPath:directoryPath withIntermediateDirectories:YES attributes:NO error:nil];
NSMutableArray *FilesArray=[[NSMutableArray alloc] initWithObjects:@"path1",@"path2"]];//add file Paths To FilesArray
for(int i=0;i<[FilesArray count];i++)
{
NSString *str=[directoryPath copy];
str=[str stringByAppendingPathExtension:[NSString stringWithFormat:@"File %i",i+1]];
NSData *FileData = [[NSData alloc] initWithContentsOfFile:[FilesArray objectAtIndex:i]];
[FileData writeToFile:str atomically:NO];
[str release];
}
精彩评论