如何加载驻留在我的app文件夹中的文件的内容?

时间:2021-01-28 00:31:37

Using the loadFile selector and the loadedFile delegate selector, how do I read the contents of a file which is in my application's app folder on dropbox?

使用loadFile选择器和loadedFile委托选择器,如何读取dropbox上应用程序的app文件夹中的文件内容?

Are you supposed to loadFile: intoPath: and specify an absolute path on the disk (like a tmp folder?) from which you actually read the contents after the loadedFile delegate method is called?

您是否应该loadFile:intoPath:并指定磁盘上的绝对路径(如tmp文件夹?),在调用loadedFile委托方法后实际读取内容?

Does the Dropbox IOS/OSX SDK automatically determine if the file is stored locally in the users' dropbox folder, and is at the current version, before fetching and downloading the file?

在获取和下载文件之前,Dropbox IOS / OSX SDK是否自动确定文件是否存储在用户的保管箱文件夹中,并且是否为当前版本?

Am I missing something here? Or is this the intended implementation?

我在这里错过了什么吗?或者这是预期的实施?

Sorry for the newbish question, it just doesn't seem like there's a ton of concrete documentation on how to actually use this method.

对于新问题,很抱歉,似乎没有关于如何实际使用此方法的大量具体文档。

edit (for clarification)

When I say I'd like to load the contents of the file, I want to dump the file contents into an NSString object. Sorry if that wasn't clear.

当我说我想加载文件的内容时,我想将文件内容转储到NSString对象中。对不起,如果不清楚。

1 个解决方案

#1


1  

 NSMutableArray *tempArray =[NSMutableArray arrayWithArray:[[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:Nil]];
 NSFileManager *fileManager =[NSFileManager defaultManager];
 NSString path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 path=[path stringByAppendingPathComponent:@"filename with extension"];

Now you can use path variable for loading file.

现在您可以使用路径变量来加载文件。

Have a happy Coding.!!

有一个快乐的编码。!!

#1


1  

 NSMutableArray *tempArray =[NSMutableArray arrayWithArray:[[NSFileManager defaultManager] contentsOfDirectoryAtPath:directoryPath error:Nil]];
 NSFileManager *fileManager =[NSFileManager defaultManager];
 NSString path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
 path=[path stringByAppendingPathComponent:@"filename with extension"];

Now you can use path variable for loading file.

现在您可以使用路径变量来加载文件。

Have a happy Coding.!!

有一个快乐的编码。!!