Logo

Programming-Idioms

  • Python
  • C++

Idiom #155 Delete file

Delete from filesystem the file having path filepath.

#include <filesystem>
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.
import pathlib
path = pathlib.Path(_filepath)
path.unlink()
import os
os.remove(filepath)
with Ada.Directories;
Ada.Directories.Delete_File (filepath);

New implementation...
< >
programming-idioms.org