http://www.qingpingshan.com/rjbc/swift/167567.html
http://www.cnblogs.com/madarax/p/6203567.html
自己写的:
//统计缓存大小
letdataPath =NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.documentDirectory,FileManager.SearchPathDomainMask.userDomainMask,true).first
letfileManager =FileManager.default
letfiles = fileManager.subpaths(atPath: dataPath!)
print(files)
varDocSize:UInt64=0
forfileinfiles!{
iffile.hasSuffix("mp4")||file.hasSuffix("MP4")||file.hasSuffix("Mp4"){
letpath = dataPath!+"/\(file)"
do{
letfloder:NSDictionary=try!fileManager.attributesOfItem(atPath: path)asNSDictionary
//判断后缀是否为MP4,MP3,ACC
print(floder)
DocSize += floder.fileSize()
}catch_{
}
}
}
网友评论