#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;
int main() {
try {
// Define the path to the file to be removed
fs::path filePath = "path/to/your/file.txt";
// Check if the file exists before attempting to remove it
if (fs::exists(filePath)) {
// Remove the file using the remove function
fs::remove(filePath);
// Print a success message if the file removal was successful
std::cout << "File removed successfully." << std::endl;
} else {
// Print an error message if the file does not exist
std::cerr << "Error: File not found." << std::endl;
}
} catch (const std::exception& e) {
// Print an error message if an exception occurs during the process
std::cerr << "Error: " << e.what() << std::endl;
}
return 0;
}