我想知道目錄中的內容或其文檔或任何其他內容。 如果有一個文件或多個我需要這些文件名。 其實我在創建文檔目錄.. 出口目錄,如果出口是空的話,我從複製主束的zip文件導出文件夾如何查找iPhone中的文檔目錄中的內容
,但下面的代碼無法正常工作。雖然出口是空的,它不會進入,如果塊..有沒有隱藏的文件..?在最後一個循環中它沒有做任何事情。
如何做到這一點。
請幫我
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);
不能確定其working.i添加完整的代碼.. – rockey 2010-10-14 20:15:29
'fileExistsAtPath:沒有按'不檢查'export'目錄是否包含任何文件,只檢查它是否存在。由於您在前一行創建它,因此條件始終爲false。 – 2010-10-14 21:35:00
好的......謝謝Can。 – rockey 2010-10-15 11:07:20