从网上看到的,于是赶紧记录下来。

 

 1 //头文件 
 2 #include "stdio.h" 
 3 #include "stdlib.h" 
 4 #include <sys/stat.h> 
 5 //代码 
 6 int main() 
 7 
 8     char* fileName = "aa.txt"
 9     struct _stat buf; 
10     int result; 
11     result = _stat( fileName, &buf ); 
12     if(_S_IFDIR & buf.st_mode){ 
13         printf("folder\n"); 
14     }else if(_S_IFREG & buf.st_mode){ 
15         printf("file\n"); 
16     } 
17 
18     return 0
19 

 

posted on 2010-02-27 15:17  漫长路  阅读(5821)  评论(4编辑  收藏  举报
宝宝客 www.baobaoke.com