Swift gets the file size based on the path

        var fileSize : UInt64 = 0
         
        do {
            let attr = try FileManager.default.attributesOfItem(atPath: path)
            fileSize = attr[FileAttributeKey.size] as! UInt64
             
            let dict = attr as NSDictionary
            fileSize = dict.fileSize()
        } catch {
            print("Error: \(error)")
        }

fileSize is the file size

Guess you like

Origin blog.csdn.net/bitcser/article/details/90785528