gpt4 book ai didi

ios - 使用 Swift 从 documentDirectory 中删除文件夹

转载 作者:行者123 更新时间:2023-11-29 05:10:00 38 4
gpt4 key购买 nike

我在文件目录中创建了一个 VideoAssets 文件夹,如下所示,其中可以包含一个或多个视频资源:

file:///private/var/mobile/Containers/Data/Application/2E3H5FDD-825D-407A-A8BE-71CD540A6E15/Documents/VideoAssets/ae6e4f59be0bc5984b043e.mp4

需要定期清理。如何清空该文件夹或完全删除 VideoAssets 文件夹?有大量关于创建文件夹的信息,但没有关于删除文件夹的信息。

最佳答案

只需使用尝试 FileManager.default.removeItem(at:directoryUrl)

来自苹果的文档:

A file URL specifying the file or directory to remove. If the URL specifies a directory, the contents of that directory are recursively removed. You may specify nil for this parameter.

https://developer.apple.com/documentation/foundation/filemanager/1413590-removeitem

关于ios - 使用 Swift 从 documentDirectory 中删除文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59778667/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com