Brandon E. answered 01/26/25
Seasoned Software Engineer specializing in C++, C# or Java
For C++, it depends on the standard version. For C++11, you can use the std::ifstream like:
std::fstream file(fileName);
return file.good();
For C++17 and higher, and especially if you have to deal with many files, you can use the std::filesystem::exists method:
return std::filesystem::exists(fileName);
Hope this helps!
Brandon