I have created a folder inside documents directory using :
fileManager.createDirectory(atPath:ziPFolderPath,withIntermediateDirectories: false, attributes: nil)
In this folder I have placed few files.
Later in the app, I want to delete not just the files inside the above folder, but also the folder.
FileManager
supports removeItem
function but I am wondering if it removes the folder as well.
Yes it will delete folder also.
From the documentation of: - removeItem(at:)
Removes the file or directory at the specified URL.
From the documentation of: - removeItem(atPath:)
Removes the file or directory at the specified path.
Edit: You can call it like this way.
try? FileManager.default.removeItem(at: URL(fileURLWithPath: ziPFolderPath))
//OR
try? FileManager.default.removeItem(atPath: ziPFolderPath)