Show pageOld revisionsBacklinksExport to PDFBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== C++ Check if folder or file exists (linux) ====== Since everything is a file in linux, the procedure is the same both for folders and files <code cpp> #include <stdio.h> #include <iostream> #include <fstream> int main() { if (std::ifstream("/folder")) { //folder std::string badge = "/folder/file"; if (std::ifstream(badge)) { std::cout << "File exists" << std::endl; } else { std::cout << "File doesn't exist" << std::endl; } } else { std::cout << "Folder doesn't exist" << std::endl; } return 0; } </code> development/cpp/folderfile_exist.txt Last modified: 2019/10/31 09:04by 127.0.0.1