简体   繁体   English

从路径解码文件名(Swift 5)

[英]Decode file name from path (Swift 5)

let FileName = ("\(urls[0])" as NSString).lastPathComponent

full file url: file:///private/var/mobile/Containers/Data/Application/2BA0F976-0A79-43E8-B5E6-28A8F0AE4D63/tmp/vladKarlugin.Documents-Inbox/Car%20Configurator.pdf完整文件网址: file:///private/var/mobile/Containers/Data/Application/2BA0F976-0A79-43E8-B5E6-28A8F0AE4D63/tmp/vladKarlugin.Documents-Inbox/Car%20Configurator.pdf

Im get file name from path "Car%20Configurator.pdf" , but true name is "Car Configuration"我从路径"Car%20Configurator.pdf"获取文件名,但真实名称是"Car Configuration"

How can I'm decode name?我怎样才能解码名字?

创建一个 URL,删除路径扩展并获取最后一个路径组件。

let fileName = URL(string: urls[0])!.deletingPathExtension().lastPathComponent

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

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