delete

abstract fun delete(path: Path, mustExist: Boolean = true)(source)

Deletes a file or directory the path points to from a filesystem. If there is no filesystem entity represented by the path this method throws kotlinx.io.files.FileNotFoundException when mustExist is true.

Note that in the case of a directory, this method will not attempt to delete it recursively, so deletion of non-empty directory will fail.

Parameters

path

the path to a file or directory to be deleted.

mustExist

the flag indicating whether missing path is an error, true by default.

Throws

when path does not exist and mustExist is true.

if deletion failed.