2011-04-06 5 views
1

안녕하세요, 주어진 서버에서 모든 파일을 읽으려고합니다. 내가하고 싶은 것 :URL의 모든 폴더 가져 오기

  • 모든 폴더

내가 내 서버의 폴더와 filey를 얻기 위해이 시도 폴더 안에있는 파일의 URL을 가져 읽기,하지만 나를을 반환

NSURL *directory = [NSURL URLWithString:@"linktoserver"]; 
NSFileManager *fileManager = [NSFileManager defaultManager]; 
NSError *error = nil; 
self.contentList = [[NSArray alloc] initWithArray:[fileManager contentsOfDirectoryAtURL:directory includingPropertiesForKeys:[[NSArray alloc] initWithObjects:NSURLNameKey, nil] options:NSDirectoryEnumerationSkipsHiddenFiles error:&error]]; 
if (error != nil) { 
    NSLog(@"ERROR: %@",[error localizedDescription]); 
} 
NSLog(@"%@",contentList); 

로그 :

> 2011-04-06 15:37:38.413 Bildergalerie[744:207] (
>  "file://localhost/Applications/", 
>  "file://localhost/Benutzerhandbu%CC%88cher%20und%20Informationen", 
>  "file://localhost/Cancel", 
>  "file://localhost/Developer/", 
>  "file://localhost/Library/", 
>  "file://localhost/opt/", 
>  "file://localhost/Shockwave%20Log", 
>  "file://localhost/System/", 
>  "file://localhost/Users/", 
>  "file://localhost/usr/") 
내 맥북의 폴더와 배열

답변을 찾을 수있는 사람은 누구 있습니까? 나는 정말로 혼란스럽고 구글은 좋은 해결책이나 튜토리얼을 찾지 못했다.

고마워, mavrick3.

답변

0

당신은 NSFileManager를 사용하여 원격 폴더에 액세스 할 수 없습니다 XML 파일/파일의 URL을 폴더를 제공한다 서버 측 파일을 작성해야합니다. 이 클래스는 로컬 디렉토리에만 액세스 할 수 있습니다.
서버가 FTP 연결을 지원하면 CFFTPStream을 사용할 수 있습니다.
CFFTPStream Reference

0

그래서 올바르게 이해하면 읽을 폴더의 모든 폴더 목록이 있지만 각 폴더의 특정 파일이 필요합니까?

그런데 for-loop를 만들지 않으시겠습니까?

for (int i = 0; i < [contentlist count]; i++ 
{ 
    //do your trick to get the file in the folder 
    //save it 
} 

편집 : 당신이 당신의 맥 대신 당신이 필요로하는 서버에서 파일을 가져 의미하는 경우에, 당신은 contentsOfDirectoryAtURL:@"http://localhost/myserver/ 같은에 선 contentsOfDirectoryAtURL:directory을 변경해야합니다.

1

NSFileManager로는이 작업을 수행 할 수 없습니다. NSFileManager는 서버가 아닌 파일 시스템 (장치의 파일 시스템)을 사용하기위한 것입니다.

당신은 당신이