ディレクトリ内のドキュメントまたはその他の内容を知りたいです。ファイルが 1 つまたは複数ある場合は、それらのファイル名が必要です。実際には、ドキュメント ディレクトリにエクスポート ディレクトリを作成しています。エクスポートが空の場合は、zip ファイルをメイン バンドルからエクスポート フォルダにコピーしています。
しかし、次のコードは機能しません。エクスポートは空ですが、ブロックされている場合はそこには入っていません..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);