シリーズもの一覧
1/4 https://qiita.com/macchan/items/30d81c4cb66a52fe4b0b
2/4 https://qiita.com/macchan/items/282db3e735ed0ad4bed8
3/4 https://qiita.com/macchan/items/19a06f30e8f3c553d4cb
4/4 https://qiita.com/macchan/items/9853a6d7b4e01ad4dc8d
C++17 から std::filesystem::remove_all()
が使えます。でも、これ「読み取り専用」でも消える。結局チマチマ消していくのが無難?
main.cpp
#include <iostream>
#include <locale>
#include <filesystem>
int main()
{
setlocale(LC_ALL, "Japanese");
std::error_code err;
uintmax_t uRet = 0;
try {
uRet = std::filesystem::remove_all("D:\\Work\\Dir", err);
}
catch (const std::filesystem::filesystem_error& e) {
std::wcout << L"例外 " << e.what() << std::endl;
}
std::wcout << uRet << L" " << err.value() << std::endl;
return 0;
}