【问题标题】:Is there a function in C++ to determine if a specific certain folder in a given directory exists or not? [closed]C++ 中是否有一个函数来确定给定目录中的特定文件夹是否存在? [关闭]
【发布时间】:2013-07-09 03:38:14
【问题描述】:

C++ 中有没有这样简单的函数?任何帮助表示赞赏。

【问题讨论】:

  • 您自己尝试过什么?您是否至少尝试过 Google 搜索或此网站的搜索?

标签: c++ file directory


【解决方案1】:

您可以使用Boost's filesystem library。示例:

#include <iostream>
#include <boost/filesystem.hpp>

int main(int argc, char* argv[])
{
    boost::filesystem::path p("/path/to/directory");

    if (exists(p))
    {
        std::cout << p << " exists!" << std::endl;
    }

    return 0;
}

请注意,Boost 文件系统不是只有标头的,需要库链接。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-12
    • 2011-06-26
    • 2019-01-18
    • 2019-02-24
    • 2012-06-28
    • 2022-11-21
    • 1970-01-01
    相关资源
    最近更新 更多