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.
Open My Computer or Windows Explorer. We recommend you make sure the directory or folder is empty before proceeding, unless you intend to delete everything in it. Locate the file or folder you want to delete and right-click it. Choose the Delete option from the pop-up menu.
In Go language, you are allowed to remove all the directories and files from a directory or folder with the help of RemoveAll() function. This function removes all the directories and files from the path you will pass to this function.
Create a new variable folderExists of type Boolean and place it in Output -> Exists. The Path Exists activity returns a boolean response based on the folder existence. Add an If condition to check if folder exists. If it exists, Delete the folder using Delete activity by passing the folderPath.
Deleting a File or Folder To delete a file or folder from Jupyter Notebook, select the file or folder in the Files list and click the Delete button. NOTE: After the file or folder is deleted, click the Refresh button in the upper right corner to refresh the Jupyter page and clear the cache.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With