Error[8]: Undefined offset: 5, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在尝试使用FileManager的copyItem(at:path :)将一些(媒体)文件从一个文件夹复制到另一个文件夹,但我收到错误: CFURLCopyResourcePropertyForKey failed because it was passed an URL which has no scheme Error Domain=NSCocoaErrorDomain Code=262 我正在尝试使用fileManager的copyItem(at:path :)将一些(媒体)文件从一个文件夹复制到另一个文件夹,但我收到错误:

CFURLcopyResourcePropertyForKey Failed because it was passed an URL which has no scheme
Error Domain=NSCocoaErrorDomain Code=262 “The file Couldn’t be opened because the specifIEd URL type isn’t supported.”

我正在使用Xcode 9 beta和Swift 4.

let fileManager = fileManager.defaultlet allowedMediafiles = ["mp4","avi"]func isMediafile(_ file: URL) -> Bool {    return allowedMediafiles.contains(file.pathExtension)}func getMediafiles(from folder: URL) -> [URL] {    guard let enumerator = fileManager.enumerator(at: folder,includingPropertIEsForKeys: []) else { return [] }    return enumerator.allObjects        .flatMap {
URL(string: "/Users/xxx/Desktop/Media/")!
as? URL} .filter {
URL(string: "file:///Users/xxx/Desktop/Media/")!
.lastPathComponent.first != "." && isMediafile(
URL(fileURLWithPath: "/Users/xxx/Desktop/Media/")
) }}func move(files: [URL],to location: URL) { do { for fileURL in files { try fileManager.copyItem(at: fileURL,to: location) } } catch (let error) { print(error) }}let mediafilesURL = URL(string: "/Users/xxx/Desktop/Media/")!let movetoFolder = URL(string: "/Users/xxx/Desktop/NewFolder/")!let mediafiles = getMediafiles(from: mediafilesURL)move(files: mediafiles,to: movetoFolder)
解决方法 发生错误是因为

try fileManager.copyItem(at: fileURL,to: location.appendingPathComponent(fileURL.lastPathComponent))

创建没有方案的URL.您可以使用

[+++]

或者更简单地说,

[+++]

另请注意,在fileManager.copyItem()中,目标必须
包括文件名,而不仅仅是目的地
目录:

[+++] 总结

以上是内存溢出为你收集整理的swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL)全部内容,希望文章能够帮你解决swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 6, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在尝试使用FileManager的copyItem(at:path :)将一些(媒体)文件从一个文件夹复制到另一个文件夹,但我收到错误: CFURLCopyResourcePropertyForKey failed because it was passed an URL which has no scheme Error Domain=NSCocoaErrorDomain Code=262 我正在尝试使用fileManager的copyItem(at:path :)将一些(媒体)文件从一个文件夹复制到另一个文件夹,但我收到错误:

CFURLcopyResourcePropertyForKey Failed because it was passed an URL which has no scheme
Error Domain=NSCocoaErrorDomain Code=262 “The file Couldn’t be opened because the specifIEd URL type isn’t supported.”

我正在使用Xcode 9 beta和Swift 4.

let fileManager = fileManager.defaultlet allowedMediafiles = ["mp4","avi"]func isMediafile(_ file: URL) -> Bool {    return allowedMediafiles.contains(file.pathExtension)}func getMediafiles(from folder: URL) -> [URL] {    guard let enumerator = fileManager.enumerator(at: folder,includingPropertIEsForKeys: []) else { return [] }    return enumerator.allObjects        .flatMap {
URL(string: "/Users/xxx/Desktop/Media/")!
as? URL} .filter {
URL(string: "file:///Users/xxx/Desktop/Media/")!
.lastPathComponent.first != "." && isMediafile(
URL(fileURLWithPath: "/Users/xxx/Desktop/Media/")
) }}func move(files: [URL],to location: URL) { do { for fileURL in files { try fileManager.copyItem(at: fileURL,to: location) } } catch (let error) { print(error) }}let mediafilesURL = URL(string: "/Users/xxx/Desktop/Media/")!let movetoFolder = URL(string: "/Users/xxx/Desktop/NewFolder/")!let mediafiles = getMediafiles(from: mediafilesURL)move(files: mediafiles,to: movetoFolder)
解决方法 发生错误是因为

try fileManager.copyItem(at: fileURL,to: location.appendingPathComponent(fileURL.lastPathComponent))

创建没有方案的URL.您可以使用

或者更简单地说,

[+++]

另请注意,在fileManager.copyItem()中,目标必须
包括文件名,而不仅仅是目的地
目录:

[+++] 总结

以上是内存溢出为你收集整理的swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL)全部内容,希望文章能够帮你解决swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
Error[8]: Undefined offset: 7, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

概述我正在尝试使用FileManager的copyItem(at:path :)将一些(媒体)文件从一个文件夹复制到另一个文件夹,但我收到错误: CFURLCopyResourcePropertyForKey failed because it was passed an URL which has no scheme Error Domain=NSCocoaErrorDomain Code=262 我正在尝试使用fileManager的copyItem(at:path :)将一些(媒体)文件从一个文件夹复制到另一个文件夹,但我收到错误:

CFURLcopyResourcePropertyForKey Failed because it was passed an URL which has no scheme
Error Domain=NSCocoaErrorDomain Code=262 “The file Couldn’t be opened because the specifIEd URL type isn’t supported.”

我正在使用Xcode 9 beta和Swift 4.

let fileManager = fileManager.defaultlet allowedMediafiles = ["mp4","avi"]func isMediafile(_ file: URL) -> Bool {    return allowedMediafiles.contains(file.pathExtension)}func getMediafiles(from folder: URL) -> [URL] {    guard let enumerator = fileManager.enumerator(at: folder,includingPropertIEsForKeys: []) else { return [] }    return enumerator.allObjects        .flatMap {
URL(string: "/Users/xxx/Desktop/Media/")!
as? URL} .filter {
URL(string: "file:///Users/xxx/Desktop/Media/")!
.lastPathComponent.first != "." && isMediafile(
URL(fileURLWithPath: "/Users/xxx/Desktop/Media/")
) }}func move(files: [URL],to location: URL) { do { for fileURL in files { try fileManager.copyItem(at: fileURL,to: location) } } catch (let error) { print(error) }}let mediafilesURL = URL(string: "/Users/xxx/Desktop/Media/")!let movetoFolder = URL(string: "/Users/xxx/Desktop/NewFolder/")!let mediafiles = getMediafiles(from: mediafilesURL)move(files: mediafiles,to: movetoFolder)
解决方法 发生错误是因为

try fileManager.copyItem(at: fileURL,to: location.appendingPathComponent(fileURL.lastPathComponent))

创建没有方案的URL.您可以使用

或者更简单地说,

另请注意,在fileManager.copyItem()中,目标必须
包括文件名,而不仅仅是目的地
目录:

[+++] 总结

以上是内存溢出为你收集整理的swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL)全部内容,希望文章能够帮你解决swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL)_app_内存溢出

swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL)

swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL),第1张

概述我正在尝试使用FileManager的copyItem(at:path :)将一些(媒体)文件从一个文件夹复制到另一个文件夹,但我收到错误: CFURLCopyResourcePropertyForKey failed because it was passed an URL which has no scheme Error Domain=NSCocoaErrorDomain Code=262 我正在尝试使用fileManager的copyItem(at:path :)将一些(媒体)文件从一个文件夹复制到另一个文件夹,但我收到错误:

CFURLcopyResourcePropertyForKey Failed because it was passed an URL which has no scheme
Error Domain=NSCocoaErrorDomain Code=262 “The file Couldn’t be opened because the specifIEd URL type isn’t supported.”

我正在使用Xcode 9 beta和Swift 4.

let fileManager = fileManager.defaultlet allowedMediafiles = ["mp4","avi"]func isMediafile(_ file: URL) -> Bool {    return allowedMediafiles.contains(file.pathExtension)}func getMediafiles(from folder: URL) -> [URL] {    guard let enumerator = fileManager.enumerator(at: folder,includingPropertIEsForKeys: []) else { return [] }    return enumerator.allObjects        .flatMap {
URL(string: "/Users/xxx/Desktop/Media/")!
as? URL} .filter {
URL(string: "file:///Users/xxx/Desktop/Media/")!
.lastPathComponent.first != "." && isMediafile(
URL(fileURLWithPath: "/Users/xxx/Desktop/Media/")
) }}func move(files: [URL],to location: URL) { do { for fileURL in files { try fileManager.copyItem(at: fileURL,to: location) } } catch (let error) { print(error) }}let mediafilesURL = URL(string: "/Users/xxx/Desktop/Media/")!let movetoFolder = URL(string: "/Users/xxx/Desktop/NewFolder/")!let mediafiles = getMediafiles(from: mediafilesURL)move(files: mediafiles,to: movetoFolder)
解决方法 发生错误是因为

try fileManager.copyItem(at: fileURL,to: location.appendingPathComponent(fileURL.lastPathComponent))

创建没有方案的URL.您可以使用

或者更简单地说,

另请注意,在fileManager.copyItem()中,目标必须
包括文件名,而不仅仅是目的地
目录:

总结

以上是内存溢出为你收集整理的swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL)全部内容,希望文章能够帮你解决swift – 使用FileManager复制文件时出错(CFURLCopyResourcePropertyForKey失败,因为它传递了一个没有方案的URL)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1007722.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存