Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
- Ada
- C
- C++
- C#
- D
- Dart
- Elixir
- Fortran
- Go
- Haskell
- JS
- JS
- JS
- Java
- Java
- Lua
- PHP
- Pascal
- Perl
- Python
- Python
- Ruby
- Rust
auto r = std::filesystem::remove(filepath);
filepath can be of type std::filesystem::path, or string, or const char*...
Returns true if the file was deleted.
Returns true if the file was deleted.
try
remove(filepath);
catch (FileException fe)
writeln(fe.msg);
try /catch can be used to track exceptions.
open (10,file=filepath,status="old", iostat=ierr)
if (ierr == 0) close (10,status="delete")
You cannot delete directly, but you can delete upon closing.
Deno.remove(filepath, { recursive: true }).catch((err) => console.error(err));
For Deno runtime. Deno.removeSync is a similar function that is synchronous.
recursive can be set to false, but deleting a non-empty directory will fail.
recursive can be set to false, but deleting a non-empty directory will fail.
try {
fs.unlinkSync(filepath);
} catch (err) {
console.error(err);
}
This is synchronous.
deleteIfExists(of(filepath));
os.remove(filepath)
Directories must be empty to be removed.
unlink($filepath);
unlink $filepath;
Named after `unlink` system call in *nix
File.delete(filepath)
Raises an exception on any error.