[C 语言]判断某文件是文件夹还是文件

#include <sys/stat.h>

#include <stdio.h>

int _tmain(int argc, _TCHAR* argv[])
{

char* fileName = "D:\\aa.txt"; 
struct _stat buf; 


int result; 
result = _stat( fileName, &buf ); 
if(_S_IFDIR & buf.st_mode){ 
printf("folder\n"); 
}else if(_S_IFREG & buf.st_mode){ 
printf("file\n"); 


return 0;
}

http://blog.csdn.net/jaken99/article/details/77657480

posted @ 2017-12-02 06:59  findumars  Views(1099)  Comments(0Edit  收藏  举报