//
Main.m
Filesearchtest
//
Created by Zhang Leonardo on 11-10-31.
Copyright (c) 2011 __mycompanyname__. All rights reserved.
to discuss Via:www.renren.com/leonardozhang
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
Nsfilemanager *manager = [Nsfilemanager Defaultmanager];
If a relative relative path is converted to an absolute path
NSString *home = [@ "/users/tang/desktop/123" Stringbyexpandingtildeinpath];
NSLog (@ "Home:%@", home);
List directories under File path
Nsdirectoryenumerator *direnum = [manager enumeratoratpath:home];
Nsmutablearray *files = [Nsmutablearray arraywithcapacity:42];
NSString *filename;
while (filename = [Direnum nextobject]) {
[Files Addobject:filename];
if ([[[FileName pathextension] isequalto:@ "jpg"]) {
[Files Addobject:filename];
// }
}
Nsenumerator *fileenum;
Fileenum = [Files Objectenumerator];
For (ID filePath in fileenum) {
NSLog (@ "%@", FilePath);
}
while (filename = [Fileenum nextobject]) {
NSLog (@ "%@", filename);
// }
}
return 0;
}
Objective-c Traverse folder to view files