Я хочу знать содержимое каталога, его документов или любого другого.
если есть файл или несколько, мне нужны эти имена файлов.
на самом деле я создаю каталог экспорта в каталоге документов ..
и если экспорт пуст, то я копирую zip-файл из основного пакета в папку экспорта
но следующий код не работает. хотя экспорт пуст, он не идет к этому, если block..r есть какие-либо скрытые файлы ..? и в последнем цикле for он ничего не делает.
как это сделать.
пожалуйста, помогите мне
self.fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
self.documentsDir = [paths objectAtIndex:0];
//creating folder 'export' to recieve the file from iTunes
NSString *srcFilePath = [NSString stringWithFormat:@"%@/export", self.documentsDir];
[fileManager createDirectoryAtPath:srcFilePath
withIntermediateDirectories:NO
attributes:nil
error:nil];
//copying the zip file into exprort from bundle if export is empty
if(![fileManager fileExistsAtPath:srcFilePath]) {
NSLog(@"File exists at path: %@", srcFilePath);
NSString *resZipfile = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"zip"
inDirectory:@"pckg"];
NSLog(@"zip file path ...%@", resZipfile);
NSData *mainBundleFile = [NSData dataWithContentsOfFile:resZipfile];
[[NSFileManager defaultManager] createFileAtPath:srcFilePath
contents:mainBundleFile
attributes:nil];
}
NSString *eachPath;
NSDirectoryEnumerator *dirEnum = [fileManager enumeratorAtPath:srcFilePath];
for(eachPath in dirEnum) NSLog(@"FILE: %@", eachPath);