C++17引入了
以下是
#include <filesystem>
std::filesystem::create_directory("path/to/directory");
#include <filesystem>
std::ofstream file("path/to/file.txt");
#include <filesystem>
std::filesystem::copy("source_file.txt", "destination_file.txt");
#include <filesystem>
std::filesystem::rename("source_file.txt", "destination_file.txt");
#include <filesystem>
std::filesystem::remove("path/to/file_or_directory");
#include <filesystem>
for (const auto& entry : std::filesystem::directory_iterator("path/to/directory")) {
std::cout << entry.path() << std::endl;
}
#include <filesystem>
std::filesystem::file_status status = std::filesystem::status("path/to/file.txt");
if (std::filesystem::is_regular_file(status)) {
std::cout << "Regular file" << std::endl;
}
这些是