Answers for "how to find out if a directory exists in cpp"

2

check if directory exists cpp

#include <sys/stat.h>

bool IsPathExist(const std::string &s)
{
  struct stat buffer;
  return (stat (s.c_str(), &buffer) == 0);
}
Posted by: Guest on June-28-2021
0

how to find out if a directory exists in cpp

#include <sys/stat.h>

int main() {
	struct stat buffer;
    std::string string = "Hello";
    
    if (stat(&string.c_str(), &buffer) != 0) {
    	std::cout << "'Hello' directory doesn't exist!";
    } else {
    	std::cout << "'Hello' directory exists!";
    }
}
Posted by: Guest on July-20-2021

Code answers related to "how to find out if a directory exists in cpp"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language