【问题标题】:File or directory _findfirst C++文件或目录 _findfirst C++
【发布时间】:2015-02-09 03:14:50
【问题描述】:

我正在编写程序,它列出特定目录中的所有文件和子目录并返回目录占用的大小。 我使用函数 _findfirst64 和 _findnext64

如何知道对象是文件还是目录?

【问题讨论】:

  • 这应该被标记为“C”而不是“C++”

标签: c++ windows file directory


【解决方案1】:

http://msdn.microsoft.com/en-us/library/kda16keh.aspx

关于找到的对象的信息在第二个参数struct _finddata_t。

_finddata_t_ info;
intptr_t handle = _findfirst64("myfile", &info);
if (handle > 0)
{
    if (info->attrib & _A_SUBDIR) 
    {
        // it's a directory

【讨论】:

    猜你喜欢
    • 2016-08-23
    • 1970-01-01
    • 2016-10-11
    • 2013-05-31
    • 1970-01-01
    • 2020-08-22
    • 1970-01-01
    • 1970-01-01
    • 2013-12-09
    相关资源
    最近更新 更多