简体   繁体   English

如何快速从应用程序文档目录中获取所有文件?

[英]How to get all the files from Applications document directory in swift?

I'm new to swift language and i use this code for get document directory我是 swift 语言的新手,我使用此代码获取文档目录

let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true);

it's right but when we run the project then the second cript code changed every time and my issue is that i want to store all the recorded videos to document directory and then load that all the recorded videos to my application's custom gallery to see the application's whole recorded videos but when i store that videos then it stores in different directory on every new run.这是对的,但是当我们运行项目时,第二个脚本代码每次都会改变,我的问题是我想将所有录制的视频存储到文档目录,然后将所有录制的视频加载到我的应用程序的自定义库中以查看应用程序的整体录制的视频,但是当我存储这些视频时,它会在每次新运行时存储在不同的目录中。

so how can i fatch and load that whole recorded videos from applications document directory那么我如何才能从应用程序文档目录中获取和加载整个录制的视频

do{
    let files = try FileManager.default.contentsOfDirectory(atPath: documentsDirectory)
     for filename in files {
         print(filename)
    }
  }
     catch {
        print(error.localizedDescription)
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM