How can I tell if a given path is a directory or a file? (C/C++)

后端 未结 7 1409
误落风尘
误落风尘 2020-12-08 13:22

I\'m using C and sometimes I have to handle paths like

  • C:\\Whatever
  • C:\\Whatever\\
  • C:\\Whatever\\Somefile

Is there a way to ch

7条回答
  •  醉梦人生
    2020-12-08 14:03

    If you're using CFile you can try

    CFileStatus status;
        if (CFile::GetStatus(fileName, status) && status.m_attribute == 0x10){
           //it's directory
    }
    

提交回复
热议问题