C++文件系统

时间:2024-10-10 22:08:31

filesystem类

#include<iostream>
#include<filesystem>
using namespace std;
int main() {
	filesystem::path url("fileBox");
	if (!filesystem::exists(url))
	{
		cout << "不存在" << endl;
	}
	//路径储存,不做其他操作
    //创建单层目录:create_directory
    filesystem::create_directory("fileBox");
    error_code temp;
    filesystem::create_directory("fileBox/xx", temp);
      cout << () << endl;
    //创建多级目录:create_directories
    filesystem::create_directories("a/b//c", temp);
      cout << () << endl;
    filesystem::remove_all(url);
    auto time = filesystem::last_write_time("A");
      cout << time.time_since_epoch().count() << endl;
	return 0;
}

path类