我已阅读以下答案检查 C 中文件是否存在的最佳方法是什么? (跨平台) https://stackoverflow.com/questions/230062/whats-the-best-way-to-check-if-a-file-exists-in-c-cross-platform,但我想知道是否有更好的方法使用标准 C++ 库来做到这一点?最好根本不尝试打开该文件。
Both stat
and access
几乎无法用谷歌搜索。我应该怎么#include
使用这些?
Use 升压::文件系统 http://www.boost.org/doc/libs/1_37_0/libs/filesystem/doc/index.htm:
#include <boost/filesystem.hpp>
if ( !boost::filesystem::exists( "myfile.txt" ) )
{
std::cout << "Can't find my file!" << std::endl;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)