如何快速从文件路径获取文件名 [英] How to get the filename from the filepath in swift
本文介绍了如何快速从文件路径获取文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从给定的文件路径字符串中获取文件名?
How to get the filename from the given file path string?
例如,如果我的文件路径字符串为
For example if I have a filepath string as
file:///Users/DeveloperTeam/Library/Developer/CoreSimulator/Devices/F33222DF-D8F0-448B-A127-C5B03C64D0DC/data/Containers/Data/Application/5D0A6264-6007-4E69-A63B-D77868EA1807/tmp/trim.D152E6EA-D19D-4E3F-8110-6EACB2833CE3.MOV
,我希望得到的返回结果为
and I would like to get the return result as
trim.D152E6EA-D19D-4E3F-8110-6EACB2833CE3.MOV
谢谢您的帮助.
推荐答案
目标C
NSString* theFileName = [string lastPathComponent]
快速
let theFileName = (string as NSString).lastPathComponent
这篇关于如何快速从文件路径获取文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文