问题描述
您好我正在尝试从给定服务器读取所有文件。我想做什么:
Hi I'm trying to read all files from a given server. What I want to do:
- 阅读所有文件夹
- 获取文件夹中的文件URL
我试过这个来获取我的服务器的文件夹和文件,但是它返回了一个包含我的MacBook文件夹的数组: / p>
I tried this to get the folders and filey of my server, but it returned me an array with the folders of my MacBook:
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/" )
任何人都可以帮我找到答案吗?我真的很困惑,谷歌没有找到一个好的解决方案或教程。
Can anyone help me to find the answer? I'm really confused and Google didn't find a good solution or tutorial.
非常感谢,
mavrick3。
Thanks a lot,mavrick3.
推荐答案
您无法使用NSFileManager访问远程文件夹。该类只能访问本地目录。
如果您的服务器支持FTP连接,那么您可以使用CFFTPStream。
You can not make use of NSFileManager to access the remote folders. This class is able to access the local directories only.
If your server supports FTP connection then you can make use of CFFTPStream.
CFFTPStream Reference
这篇关于获取URL的所有文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!