#include<filesystem>#include<iostream>namespacefs=std::filesystem;intmain(){fs::pathp1="C:/Users/John/Documents/";fs::pathp2="C:/Users/Jane/Documents/";if(p1==p2){std::cout<<"The paths are equal"<<std::endl;}else{std::cout<<"The paths are not equal"<<std::endl;}return0;}
#include<filesystem>#include<iostream>intmain(){std::filesystem::pathcurrentPath=std::filesystem::current_path();std::cout<<"Current working directory is: "<<currentPath<<std::endl;return0;}
#include<filesystem>#include<iostream>intmain(){std::filesystem::pathdirPath="C:/mydir";if(std::filesystem::create_directory(dirPath)){std::cout<<"Directory created successfully."<<std::endl;}else{std::cout<<"Failed to create directory."<<std::endl;}return0;}
#include<filesystem>#include<iostream>namespacefs=std::filesystem;intmain(){fs::pathp="C:/Users/John/Documents/report.txt";if(fs::exists(p)){std::cout<<"The file exists"<<std::endl;}else{std::cout<<"The file does not exist"<<std::endl;}return0;}
#include<filesystem>#include<iostream>namespacefs=std::filesystem;intmain(){fs::pathp="C:/Users/John/Documents/report.txt";if(fs::exists(p)){fs::remove(p);std::cout<<"The file was successfully deleted"<<std::endl;}else{std::cout<<"The file does not exist"<<std::endl;}return0;}
#include<filesystem>#include<iostream>namespacefs=std::filesystem;intmain(){fs::pathsource="C:/Users/John/Documents/report.txt";fs::pathtarget="C:/Users/John/Documents/report_copy.txt";if(fs::exists(source)){fs::copy(source,target);std::cout<<"The file was successfully copied"<<std::endl;}else{std::cout<<"The file does not exist"<<std::endl;}return0;}
#include<filesystem>#include<iostream>namespacefs=std::filesystem;intmain(){fs::pathold_path="C:/Users/John/Documents/report.txt";fs::pathnew_path="C:/Users/John/Documents/report_renamed.txt";if(fs::exists(old_path)){fs::rename(old_path,new_path);std::cout<<"The file was successfully renamed"<<std::endl;}else{std::cout<<"The file does not exist"<<std::endl;}return0;}