阅读量:0
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; }
这些是