【发布时间】:2017-02-04 14:18:46
【问题描述】:
func getDocumentsDirectory() -> URL {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
let documentsDirectory = paths[0]
return documentsDirectory
}
很简单,我使用该函数获取我的文件名。它现在正确返回,我如何使用 Swift 3 删除这个文件?
我怎样才能像UIImageJPEGRepresentation一样读回图像?
let image_data = UIImageJPEGRepresentation(self.commons.correctlyOrientedImage(image: self.imageSelected.image!),0.5)
我做了跟踪,但它不起作用
let filename = getDocumentsDirectory().appendingPathComponent("l.png") letfileManager = FileManager.default var filePath = 文件名 // 检查文件是否存在
if fileManager.fileExists(atPath: filePath.absoluteString) { // Delete file try fileManager.removeItem(atPath: filePath.absoluteString) } else { print("File does not exist") }
我这样保存文件
let filename = getDocumentsDirectory().appendingPathComponent("COPY111.PNG") try? image_data?.write(to: filename)
但我无法从下面提供的答案中删除它
【问题讨论】: