首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ZipFoundation无法解压该文件,因为找不到该文件

ZipFoundation无法解压该文件,因为找不到该文件
EN

Stack Overflow用户
提问于 2020-07-03 01:12:58
回答 1查看 90关注 0票数 1

我正在尝试使用ZipFoundation库在macOS应用程序中解压一些归档文件。文件位于桌面上,我已确认路径正确且文件存在。

我有这样的代码:

代码语言:javascript
复制
let fileManager = FileManager()
                        
    let sourceURL = URL(fileURLWithPath: monetizeZiPFile.absoluteString)
    var destinationURL = URL(fileURLWithPath: dirBuildURL.absoluteString)
    destinationURL.appendPathComponent("directory")
                        
    do {
        try fileManager.createDirectory(at: destinationURL, withIntermediateDirectories: true, attributes: nil)
        try fileManager.unzipItem(at: monetizeZiPFile, to: dirBuildURL)
   } catch {
        print("Extraction of ZIP archive failed with error:\(error)")
   }

对于unzipItem方法,我收到以下错误:

代码语言:javascript
复制
CFURLResourceIsReachable failed because it was passed an URL which has no scheme

Extraction of ZIP archive failed with error:Error Domain=NSCocoaErrorDomain Code=260 
"The file “00-monetize.zip” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/xxxxxxxx/Desktop/Componize-Builds/DOC-8621/Monetize/00-monetize.zip}

我必须在项目目录中才能让ZipFoundation工作吗?

EN

回答 1

Stack Overflow用户

发布于 2021-02-23 11:57:52

对于路径,请使用path,而不要使用absoluteString

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62701689

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档