xcode mac如何在所有子目录中查找指定的文件类型

时间:2012-07-19 20:45:58

标签: xcode macos file list

filenamesArray = myPanel.URLs;  
arxeio=myPanel.URL.lastPathComponent;  
urll = myPanel.URL.absoluteURL;  
url = [NSURL URLWithString:arxeio];  
user_path = [[urll path] stringByDeletingLastPathComponent];  
user_path = [user_path stringByReplacingOccurrencesOfString:@"%20" withString:@" "];  
bundleRoot = [[NSBundle bundleWithPath:user_path] bundlePath];  
dirContents = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:urll includingPropertiesForKeys:NULL options:0 error:nil];  
for (i=0; i<[dirContents count]; i++){  
indirContents =  [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[dirContents objectAtIndex:i]  
includingPropertiesForKeys:NULL options:0 error:nil];            
if([indirContents count] > 0)  
for(s=0; s<[indirContents count]; s++){  
secIndirContents = NULL;  
secIndirContents =  [[NSFileManager defaultManager] contentsOfDirectoryAtURL:[indirContents objectAtIndex:s]  
includingPropertiesForKeys:NULL options:0 error:nil]; 
user_paths = @"";  
user_paths = [user_paths stringByAppendingString:[indirContents objectAtIndex:s]];  
urll = [[indirContents objectAtIndex:s] absoluteURL];  
user_paths = [urll path];  
user_paths = [user_paths stringByReplacingOccurrencesOfString:@"%20" withString:@" "];  
[arxeia_directories addObject:user_paths];  
  

我使用此代码从给定路径读取文件,但我可以阅读   只有2个深度的子目录,有没有办法读取给定路径中所有&gt;子目录中的所有文件?

0 个答案:

没有答案