App Path : NSLog(@"[[NSBundle mainBundle] bundlePath]=%@", [[NSBundle mainBundle] bundlePath] );
DocumentDirectory : NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
------------
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
NSArray *fileList = nil;//[[[NSArray alloc] init] autorelease];
//fileList便是包含有该文件夹下所有文件的文件名及文件夹名的数组
fileList = [fileManager contentsOfDirectoryAtPath:documentsDirectory error:&error];
NSMutableArray *array = [[[NSMutableArray alloc] init] autorelease];
for (NSString *iStr in fileList) {
NSString *subStr = [iStr substringFromIndex:[iStr length]-4];
if ([subStr isEqualToString:@".txt"]) {
NSLog(@"iStr=%@",iStr);
[array addObject:iStr];
}
}
-----------