Replace Filename Extension (C++17)

Note this only works in C++ 17 (or boost::filesystem on lower):

#include <filesystem>

namespace fs = std::filesystem;

fs::path p(full_path);
p.replace_extension();

.replace_extension() by default removes an extension, but you can pass what to replace it with, for instance .replace_extension(L".png").

Have a question⁉ Contact me.

cpp

38 Words

2021-07-08