How to get All paths for files in Documents directory?

前端 未结 3 926
名媛妹妹
名媛妹妹 2020-12-13 21:41

I usually get paths by using NSBundle.

But, NSBundle does not contain Documents folder.

How to get All paths(or names) for files in

3条回答
  •  孤城傲影
    2020-12-13 22:20

        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *documentsDirectory = [paths objectAtIndex:0];
    

    To get files from that, you have to give the path structure...

        NSString *fileName = @"default.png";
        NSString *folderPath = [documentsDirectory stringByAppendingPathComponent:@"%@", fileName];
    

    The folderPath will return you the location of given file name.

提交回复
热议问题