0
我試着去閱讀文檔的特定文件夾的內容目錄,多數民衆贊成只包含PNG的/Documents/ApplianceImagesFolder/
獲取文檔中特定文件夾的內容diectory
目前我只可以從文件夾我的圖片,我怎麼能目標內容只有ApplianceImagesFolder
?
//gets all png form documents folder
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSArray *dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsPath error:nil];
fileList=[[NSMutableArray alloc]init];
for (NSString *dir in dirContents) {
if ([dir hasSuffix:@".png"]) {
NSRange range = [dir rangeOfString:@"."];
NSString *name = [dir substringToIndex:range.location];
if (![name isEqualToString:@""]) {
[fileList addObject:name];
}
}
}
NSLog(@"document folder content list %@ ",fileList);
你嘗試枚舉只是目錄, ? –
檢查這[post](http://www.techotopia.com/index.php/Working_with_Directories_on_iPhone_OS) – Pawan